Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_print.cpython-311.opt-1.pyc
�

�Ke��	��ddlZddlZddlmZddlmZe��Zd�d�d�d�d�d	�d
�d�d�ZGd
�d��Z	Gd�dej
��ZGd�dej
��Ze
dkrej��dSdS)�N)�StringIO)�supportc��t|�S�N��print��args�sep�end�files    �9/usr/local/apps/python3/lib/python3.11/test/test_print.py�<lambda>rs
��U�D�\��c��t|d|i�S)Nr
rr	s    rrrs��U�t�%<��%<�%<�rc��t|d|i�S)Nrrr	s    rrr���U�T�%:�s�%:�%:�rc��t|||d��S)N)rr
rr	s    rrr���U��s��%E�%E�%E�rc��t|d|i�S)Nrrr	s    rrrrrc��t|||d��S)N)rr
rr	s    rrrrrc��t|||d��S)N�rrrr	s    rrrs��U�d�s��%C�%C�%C�rc��t||||d��S)N�rrr
rr	s    rrrs��U��s��$�%N�%N�%N�r))FFF)FFT)FTF)FTT)TFF)TFT)TTF)TTTc��eZdZd�Zd�ZdS)�ClassWith__str__c��||_dSr��x��selfr s  r�__init__zClassWith__str__.__init__$s
������rc��|jSrr�r"s r�__str__zClassWith__str__.__str__'s	���v�
rN)�__name__�
__module__�__qualname__r#r&�rrrr#s2�������������rrc�,�eZdZdZeeefd�Zd�Zd�ZdS)�	TestPrintz-Test correct operation of the print function.c��t|tu|tu|tuf}tj��5}|||||��ddd��n#1swxYwY|�|���|��dSr)�dispatch�
NotDefinedr�captured_stdout�assertEqual�getvalue)r"�expectedr
rrr
�fn�ts        r�checkzTestPrint.check.s����s�*�,��*�,��:�-�/�0���
$�
&�
&�	%�!��B�t�S�#�t�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	
��������x�0�0�0�0�0s�A�A�Ac���ttf�fd�	}|dd��|dd��|dd��|dd	��|d
d��|dd	d
���|ddd���|ddd���|dddd���|ddd
d���|ddd���|ddd���|dd��|ddd���|ddd���|dddd���|d td
��f��|d!td"��d#f����ttdd$�����ttdd$�����t
tdd�%��dS)&Nc������||||���t��}��d||||�����|���|��dS)Nr�r)r6rr1r2)r3r
rr�or"s     �rr zTestPrint.test_print.<locals>.x@sl���
�J�J�x��3�C�J�8�8�8��
�
�A��J�J�r�4�S�c��J�:�:�:�
���Q�Z�Z�\�\�8�4�4�4�4�4r�
r*�a
)�azNone
rz1 2
)��z1   2
)r>� r?z1*2
�*)rz1 s)r>�sr9)rza
b
)r=�bz1.01)g�?r>rz1*a*1.3+)r>r=g�������?�+za

b
)r<rCz+ +
)�r@rEza
 b
z*
zabc 1
�abcr>�)r
)r/r�assertRaises�	TypeErrorr�AttributeErrorr!s` r�
test_printzTestPrint.test_print?s���",�*�	5�	5�	5�	5�	5�	5�	
��$�����	��%�����	��(�G����	��'�6����	��)�[�!�!�!�	��'�6�s�#�#�#�#�	��%��r�"�"�"�"�	��(�J�D�)�)�)�)�	��&�(���+�+�+�+�	��*�m��#�6�6�6�6�	��*�l��-�-�-�-�	��+�(�c�2�2�2�2�	��)�\�"�"�"�	��)�\�t�,�,�,�,�	��)�\�t�,�,�,�,�	��)�\�t��6�6�6�6�	��%�"�3�'�'�)�*�*�*�	��)�&�u�-�-�q�1�2�2�2�	
���)�U�B�A��6�6�6����)�U�B�A��6�6�6����.�%��"��=�=�=�=�=rc��Gd�d��}|��}td|dd���td|dd���td|d	�
��|�|jd��|�|jd��Gd�d
��}|�t
td|��d�
��dS)Nc� �eZdZd�Zd�Zd�ZdS)�,TestPrint.test_print_flush.<locals>.filelikec�"�d|_d|_dS)Nr9r)�written�flushedr%s rr#z5TestPrint.test_print_flush.<locals>.filelike.__init__js��!��� ����rc�&�|xj|z
c_dSr)rP�r"�strs  r�writez2TestPrint.test_print_flush.<locals>.filelike.writens������#����rc�&�|xjdz
c_dS)Nr>)rQr%s r�flushz2TestPrint.test_print_flush.<locals>.filelike.flushqs������!����rN)r'r(r)r#rUrWr*rr�filelikerNisA������
!�
!�
!�
$�
$�
$�
"�
"�
"�
"�
"rrXr>r9T)r
rrWr?rGF)r
rWz123
c��eZdZd�Zd�ZdS)�+TestPrint.test_print_flush.<locals>.noflushc��dSrr*rSs  rrUz1TestPrint.test_print_flush.<locals>.noflush.write}s���rc��t�r)�RuntimeErrorr%s rrWz1TestPrint.test_print_flush.<locals>.noflush.flush�s��"�"rN)r'r(r)rUrWr*rr�noflushrZ|s2������
�
�
�
#�
#�
#�
#�
#rr^)rr1rPrQrHr])r"rX�fr^s    r�test_print_flushzTestPrint.test_print_flushgs���		"�		"�		"�		"�		"�		"�		"�		"�
�H�J�J��
�a�a�R�t�,�,�,�,�
�a�a�R�t�,�,�,�,�
�a�a�u�%�%�%�%������G�,�,�,������A�&�&�&�	#�	#�	#�	#�	#�	#�	#�	#�	
���,��q�w�w�y�y���M�M�M�M�MrN)r'r(r)�__doc__r/r6rKr`r*rrr,r,+s[������7�7��*�:�1�1�1�1�"&>�&>�&>�PN�N�N�N�Nrr,c�<�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
�TestPy2MigrationHintzwTest that correct hint is produced analogous to Python3 syntax,
    if print statement is executed as in Python 2.
    c���d}|�t��5}t|��ddd��n#1swxYwY|�dt	|j����dS)Nzprint "Hello World"�?Missing parentheses in call to 'print'. Did you mean print(...)�rH�SyntaxError�exec�assertInrT�	exception�r"�python2_print_str�contexts   r�test_normal_stringz'TestPy2MigrationHint.test_normal_string����1��
�
�
�{�
+�
+�	$�w��"�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	
�
�
�W��G�%�&�&�	(�	(�	(�	(�	(�
�9�=�=c���d}|�t��5}t|��ddd��n#1swxYwY|�dt	|j����dS)Nzprint "Hello World",rerfrks   r�test_string_with_soft_spacez0TestPy2MigrationHint.test_string_with_soft_space�s���2��
�
�
�{�
+�
+�	$�w��"�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	
�
�
�W��G�%�&�&�	(�	(�	(�	(�	(rpc���d}|�t��5}t|��ddd��n#1swxYwY|�dt	|j����dS)Nzprint  "Hello World", rerfrks   r�%test_string_with_excessive_whitespacez:TestPy2MigrationHint.test_string_with_excessive_whitespace�s���4��
�
�
�{�
+�
+�	$�w��"�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	
�
�
�W��G�%�&�&�	(�	(�	(�	(�	(rpc���d}|�t��5}t|��ddd��n#1swxYwY|�dt	|j����dS)Nz.if 1:
            print "Hello World"
        rerfrks   r�#test_string_with_leading_whitespacez8TestPy2MigrationHint.test_string_with_leading_whitespace�s������
�
�{�
+�
+�	$�w��"�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	
�
�
�W��G�%�&�&�	(�	(�	(�	(�	(rpc���d}|�t��5}t|��ddd��n#1swxYwY|�dt	|j����dS)Nzprint p;rerfrks   r�test_string_with_semicolonz/TestPy2MigrationHint.test_string_with_semicolon�s���&��
�
�
�{�
+�
+�	$�w��"�#�#�#�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	
�
�
�W��G�%�&�&�	(�	(�	(�	(�	(rpc���d}|�t��5}t|��ddd��n#1swxYwY|�dt	|j����dS)Nzfor i in s: print irerfrks   r� test_string_in_loop_on_same_linez5TestPy2MigrationHint.test_string_in_loop_on_same_line�rorpc���|�t��5}ttjz	dfddd��n#1swxYwY|�dt
|j����|�t��5}tdz	ddd��n#1swxYwY|�dt
|j����|�t��5}ttjz	ddd��n#1swxYwY|�	dt
|j����|�t��5}ttjzddd��n#1swxYwY|�	dt
|j����Gd�d��}|�
t|��z	d��dS)N�messagez6Did you mean "print(<message>, file=<output_stream>)"?�*z
Did you mean zDid you meanc��eZdZd�ZdS)�\TestPy2MigrationHint.test_stream_redirection_hint_for_py2_migration.<locals>.OverrideRRShiftc��dS)Nr}r*)r"�lhss  r�__rrshift__zhTestPy2MigrationHint.test_stream_redirection_hint_for_py2_migration.<locals>.OverrideRRShift.__rrshift__�s���rrN)r'r(r)r�r*rr�OverrideRRShiftr�s#������
�
�
�
�
rr�)rHrIr�sys�stderrrirTrj�max�assertNotInr1)r"rmr�s   r�.test_stream_redirection_hint_for_py2_migrationzCTestPy2MigrationHint.test_stream_redirection_hint_for_py2_migration�s���
�
�
�y�
)�
)�	+�W��S�Z���*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+��
�
�*�+.�w�/@�+A�+A�	C�	C�	C�
�
�
�y�
)�
)�	�W��R�K�K�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��
�
�*�+.�w�/@�+A�+A�	C�	C�	C��
�
�y�
)�
)�	�W��3�:���	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�����#�g�.?�*@�*@�A�A�A��
�
�y�
)�
)�	 �W��S�Z���	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ������W�->�)?�)?�@�@�@�	�	�	�	�	�	�	�	�	
����/�/�"3�"3�3�R�8�8�8�8�8sE�>�A�A�B"�"B&�)B&�/D�D�D�E>�>F�FN)r'r(r)rarnrrrtrvrxrzr�r*rrrcrc�s���������(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�(�9�9�9�9�9rrc�__main__)�unittestr��ior�testr�objectr/r.r�TestCaser,rcr'�mainr*rr�<module>r�sF������
�
�
�
�������������
�V�X�X�
�	2�1�<�<�:�:�E�E�:�:�E�E�C�C�N�N�!���*��������WN�WN�WN�WN�WN��!�WN�WN�WN�tW9�W9�W9�W9�W9�8�,�W9�W9�W9�v�z����H�M�O�O�O�O�O��r