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

�Ke�5��@�	ddlmZmZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
ddlmZddddd	d
d�ZGd�d
��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZdS)�)�TestCase�mockN)�captured_stderr�captured_stdout�
script_helper�findfile)�unlinkzCfruits = [
    "Apple",
    "Orange",
    "Banana",

print(fruits)
zLif True:
    print("hello")
  print("world")
else:
    print("else called")
zIif True:
 	print("hello")
	print("world")
else:
    print("else called")
zNif True:
    print("hello")
    print("world")
else:
    print("else called")
zGdef my_func():
	  print("hello world")
	  if True:
		print("If called")zLdef my_func():
		print("Hello world")
		if True:
	        print("If called"))�incomplete_expression�wrong_indented�nannynag_errored�
error_free�tab_space_errored_1�tab_space_errored_2c�$�eZdZ	dd�Zd�Zd�ZdS)�TemporaryPyFile�Nc�"�||_||_dS�N)�source_code�dir)�selfr�	directorys   �</usr/local/apps/python3/lib/python3.11/test/test_tabnanny.py�__init__zTemporaryPyFile.__init__Bs��&��������c���tjd|jdd���5}|�|j��ddd��n#1swxYwY|j|_|jS)N�wz.pyF)�moder�suffix�delete)�tempfile�NamedTemporaryFiler�writer�name�	file_path)r�fs  r�	__enter__zTemporaryPyFile.__enter__Fs���
�
(��$�(�5��
�
�
�	&�
�
�G�G�D�$�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&������~�s�A�A	�A	c�.�t|j��dSr)r	r%)r�exc_type�	exc_value�
exc_tracebacks    r�__exit__zTemporaryPyFile.__exit__Ns���t�~�����r)rN)�__name__�
__module__�__qualname__rr'r,�rrrr?sI������5������������rrc��eZdZ	d�ZdS)�TestFormatWitnessesc���	gd�}|D]\\}}|�||���5|�tj|��|��ddd��n#1swxYwY�]dS)N))�Testzat tab sizes T, e, s, t)rzat tab size )�tz
at tab size t)z  t  zat tab sizes  ,  , t,  ,  )�words�expected)�subTest�assertEqual�tabnanny�format_witnesses)r�testsr6r7s    r�test_format_witnessesz)TestFormatWitnesses.test_format_witnessesUs���I�
�
�
�� %�	M�	M�O�E�8����E�H��=�=�
M�
M�� � ��!:�5�!A�!A�8�L�L�L�
M�
M�
M�
M�
M�
M�
M�
M�
M�
M�
M����
M�
M�
M�
M��	M�	Ms�)A�A	� A	N)r-r.r/r=r0rrr2r2Rs+������0�M�M�M�M�Mrr2c��eZdZ	d�ZdS)�TestErrPrintc�T�	ddgdfdgdfgd�dfgdfg}|D]�\}}|�||���5t��5}tj|�ddd��n#1swxYwY|�|���|��ddd��n#1swxYwY��dS)	N�first�secondz
first second
zfirst
)���z1 2 3
�
)�	argumentsr7)r8rr:�errprintr9�getvalue)rr<�argsr7�stderrs     r�
test_errprintzTestErrPrint.test_errprintfsN��P��x�
 �"2�3��Y�	�"�
�Y�Y�	�"�
��J�	
��$�	?�	?�N�D�(�����x��@�@�
?�
?�$�&�&�-�&��%�t�,�,�-�-�-�-�-�-�-�-�-�-�-����-�-�-�-�� � ����!2�!2�X�>�>�>�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?��	?�	?s5�B�A�B�A!�!B�$A!�%+B�B 	�#B 	N)r-r.r/rLr0rrr?r?cs&������(�
?�
?�
?�
?�
?rr?c��eZdZd�ZdS)�TestNannyNagc���	tjddd��dddd�ftjddd��dddd�fg}|D�]5\}}|���}|���}|���}|�||d�	��5|�|d|��ddd��n#1swxYwY|�||d
���5|�|d
|��ddd��n#1swxYwY|�||d�
��5|�|d|��ddd��n#1swxYwY��7dS)Nr�foo�bar)�lineno�msg�line��testmsg�testlinerR)�line_numberr7rS)rSr7rT)rTr7)r:�NannyNag�
get_lineno�get_msg�get_liner8r9)rr<�nannyr7rXrSrTs       r�test_all_methodszTestNannyNag.test_all_methodswsa��C��!�!�U�E�2�2��U�E�:�:�
�
�!�!�Y�
�;�;��Y�
�C�C�
�	
�� %�	9�	9�O�E�8��*�*�,�,�K��-�-�/�/�C��>�>�#�#�D����'�(�8�2D����
B�
B�� � ��(�!3�[�A�A�A�
B�
B�
B�
B�
B�
B�
B�
B�
B�
B�
B����
B�
B�
B�
B����#�����@�@�
7�
7�� � ��%��#�6�6�6�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7����
7�
7�
7�
7����4�(�6�2B��C�C�
9�
9�� � ��&�!1�4�8�8�8�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9�
9����
9�
9�
9�
9��	9�	9s6�C�C	�C	�,D�D	�D	�=E&�&E*	�-E*	N)r-r.r/r^r0rrrNrNvs#������9�9�9�9�9rrNc�T�eZdZ	d�Zdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
S)�	TestCheckc�v�|�ttdtj��dt_dS)N�verboser)�
addCleanup�setattrr:rb)rs r�setUpzTestCheck.setUp�s+�������9�h�6F�G�G�G�����rrc�h�	t��5}t��5}tj|��ddd��n#1swxYwYddd��n#1swxYwY|�|���|��|�|���|��dSr)rrr:�checkr9rI)r�dir_or_file�out�err�stdoutrKs      r�verify_tabnanny_checkzTestCheck.verify_tabnanny_check�s��	��
�
�	(�&�/�*;�*;�	(�v��N�;�'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�������*�*�C�0�0�0�������*�*�C�0�0�0�0�0s3�A�A�A�A	�A�A	�A�A�Ac��	ttd��5}|�|��ddd��dS#1swxYwYdS�Nr
�r�SOURCE_CODESrl�rr%s  r�test_correct_filezTestCheck.test_correct_file�s���;�
�\�,�7�
8�
8�	2�I��&�&�y�1�1�1�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	2�	2��?�A�Ac
�d�	tj��5}|�d�g}ttd|���}ttd|���}|5}|5}||fD]}|�|�d����dt
_t��5}t��5}	tj	|��ddd��n#1swxYwYddd��n#1swxYwY|�
��}|D]F}
|�|
���5|�|
|��ddd��n#1swxYwY�G|�
|	�
��d��ddd��n#1swxYwYddd��n#1swxYwYddd��dS#1swxYwYdS)Nz: listing directory
r
�rz: Clean bill of health.
rC)rTr)r!�TemporaryDirectoryrrp�appendr:rbrrrgrIr8�assertInr9)r�tmp_dir�lines�file1�file2�
file1_path�
file2_pathr%rkrKrTs           r�test_correct_directory_verbosez(TestCheck.test_correct_directory_verbose�s*��	��
(�
*�
*�	8�g��8�8�8�:�E�#�L��$>�'�R�R�R�E�#�L��$>�'�R�R�R�E��
8�*�e�
8�z�",�j�!9�L�L�I��L�L�I�!J�!J�!J�K�K�K�K�#$�� �$�&�&�,�&�/�2C�2C�,�v��N�7�+�+�+�,�,�,�,�,�,�,�,�,�,�,����,�,�,�,�,�,�,�,�,�,�,�,�,�,�,����,�,�,�,����*�*��!�4�4�D����4��0�0�4�4��
�
�d�F�3�3�3�4�4�4�4�4�4�4�4�4�4�4����4�4�4�4��� � ����!2�!2�B�7�7�7�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8����
8�
8�
8�
8�		8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8s��AF%�F
�:E6�C	�"C�7C	�C�C	�
C�C	�E6�C
�E6�!C
�"1E6�D6�*E6�6D:�:E6�=D:�>,E6�*F
�6E:�:F
�=E:�>F
�F%�
F	�F%�F	�F%�%F)�,F)c���	tj��5}ttd|���5|�|��ddd��n#1swxYwYddd��dS#1swxYwYdS)Nr
ru�r!rvrrprl)rrys  r�test_correct_directoryz TestCheck.test_correct_directory�s���O�
�
(�
*�
*�	4�g� ��l�!;�w�O�O�O�
4�
4��*�*�7�3�3�3�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4����
4�
4�
4�
4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�	4�	4s4�A,�A�A,�A	�A,�A	�A,�,A0�3A0c��	ttd��5}d}|�d|��}|�||���ddd��dS#1swxYwYdS)Nr�Iunindent does not match any outer indentation level (<tokenize>, line 3)
�: Indentation Error: �rjro�rr%rjs   r�test_when_wrong_indentedz"TestCheck.test_when_wrong_indented�s���P�
�\�*:�;�
<�
<�	;�	�*�C��<�<�s�<�<�C��&�&�y�c�&�:�:�:�		;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;��!A
�
A�Ac��	ttd��5}d}|�d|��}|�||���ddd��dS#1swxYwYdS)Nr
z(('EOF in multi-line statement', (7, 0))
z: Token Error: r�ror�s   r�test_when_tokenize_tokenerrorz'TestCheck.test_when_tokenize_tokenerror�s���S�
�\�*A�B�
C�
C�	;�y�=�C��6�6��6�6�C��&�&�y�c�&�:�:�:�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;r�c���	ttd��5}|�d�}|dz
}|dz
}dt_|�||���ddd��dS#1swxYwYdS)Nrz': *** Line 3: trouble in tab city! ***
z%offending line: '\tprint("world")\n'
z$indent not equal e.g. at tab size 1
rC�ri)rrpr:rbrl�rr%ris   r� test_when_nannynag_error_verbosez*TestCheck.test_when_nannynag_error_verbose�s���	��\�*<�=�
>�
>�	;�)��J�J�J�C��?�?�C��:�:�C� �H���&�&�y�c�&�:�:�:�
	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;s�3A�A �#A c��	ttd��5}|�d�}|�||���ddd��dS#1swxYwYdS)Nrz 3 '\tprint("world")\n'
r�ror�s   r�test_when_nannynag_errorz"TestCheck.test_when_nannynag_error�s���Q�
�\�*<�=�
>�
>�	;�)��=�=�=�C��&�&�y�c�&�:�:�:�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;s�A�A
�
A
c��	d}|�dtj�dtjtj���d|�d�}|�||���dS)Nz
no_file.pyz: I/O Error: [Errno z] z: rFr�)�errno�ENOENT�os�strerrorrl)r�pathrjs   r�test_when_no_filezTestCheck.test_when_no_file�sq��D����9�9�e�l�9�9���U�\�*�*�9�9�.2�9�9�9���"�"�4�S�"�1�1�1�1�1rc�x�	tj��5}ttd|���}ttd|���}|5}|5}d}|�d|��}|�||���ddd��n#1swxYwYddd��n#1swxYwYddd��dS#1swxYwYdS)Nrrur
r�r�r�r�)rry�
error_file�	code_file�e_file�c_filerjs       r�test_errored_directoryz TestCheck.test_errored_directory�s���M�
�
(�
*�
*�	=�g�(��-�.�'����J�(��\�*�g����I��
=�v�y�
=�F�6���=�=��=�=���*�*�7��*�<�<�<�	
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=�
=����
=�
=�
=�
=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=�	=�	=sY�;B/�B�!B�4B�B�B�B�B�B/�B	�B/�B	�B/�/B3�6B3N)rr)r-r.r/rerlrrrr�r�r�r�r�r�r�r0rrr`r`�s�������#����1�1�1�1�2�2�2�
8�8�8�04�4�4�;�;�;�;�;�;�;�;�;�;�;�;�2�2�2�
=�
=�
=�
=�
=rr`c�H�eZdZ	ejd��d���Zd�ZdS)�TestProcessTokensztabnanny.NannyNagc�F�	ttd��5}t|��5}tjtj|j����ddd��n#1swxYwY|�|j	��ddd��dS#1swxYwYdSrn)
rrp�openr:�process_tokens�tokenize�generate_tokens�readline�assertFalse�called)r�MockNannyNagr%r&s    r�test_with_correct_codez(TestProcessTokens.test_with_correct_codes��K�
�\�,�7�
8�
8�	2�I��i���
N�A��'��(@���(L�(L�M�M�M�
N�
N�
N�
N�
N�
N�
N�
N�
N�
N�
N����
N�
N�
N�
N����\�0�1�1�1�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	2�	2s4�B�,A$�B�$A(	�(B�+A(	�,B�B�Bc
���	dD]�}|�|���5tt|��5}t|��5}t	j|j��}|�tj	��5tj
|��ddd��n#1swxYwYddd��n#1swxYwYddd��n#1swxYwYddd��n#1swxYwY��dS)N)rr)�key)r8rrpr�r�r�r��assertRaisesr:rYr�)rr�r%r&�tokenss     r�test_with_errored_codes_samplesz1TestProcessTokens.test_with_errored_codes_samples
s���L�B�	<�	<�C����#��&�&�
<�
<�$�\�#�%6�7�7�<�9��i���<�A�!)�!9�!�*�!E�!E��!�.�.�x�/@�A�A�<�<�$�3�F�;�;�;�<�<�<�<�<�<�<�<�<�<�<����<�<�<�<�<�<�<�<�<�<�<�<�<�<�<����<�<�<�<�<�<�<�<�<�<�<�<�<�<�<����<�<�<�<�
<�
<�
<�
<�
<�
<�
<�
<�
<�
<�
<����
<�
<�
<�
<��	<�	<s|�C&�C�9B8	�B!�B8	�!B%�%B8	�(B%�)B8	�,C�8B<
�<C�?B<
�C�C&�C�C&�C�C&�&C*	�-C*	N)r-r.r/r�patchr�r�r0rrr�r�sM������.��T�Z�#�$�$�2�2�%�$�2�<�<�<�<�<rr�c�D�eZdZ	dddd�d�Zd�Zd�Zd�Zd�Zd	�Zd
�Z	dS)�TestCommandLinerF)rkrK�partialc�r�	tjddg|�R�\}}}tj|��}tj|��}|r�||f||ffD]u\}}	|	���}
|���D]G}|�||
���5|�||
��ddd��n#1swxYwY�H�vdS|�|���|�����|�|���|�����dS)Nz-mr:)�std�output)r�assert_python_okr��fsdecode�
splitlinesr8rx�assertListEqual)rrkrKr�rJ�_rirjr�r��_output�_stds            r�validate_cmdzTestCommandLine.validate_cmd"s���P�#�4�T�:�M��M�M�M���3���k�#�����k�#�����	H�!'��
���}�=�
5�
5���V� �+�+�-�-���N�N�,�,�5�5�D����$�w��?�?�5�5��
�
�d�G�4�4�4�5�5�5�5�5�5�5�5�5�5�5����5�5�5�5��5�
5�
5�
� � ����!1�!1�6�3D�3D�3F�3F�G�G�G�� � ����!1�!1�6�3D�3D�3F�3F�G�G�G�G�Gs�B4�4B8�;B8c��	ttd��5}|�d�}|dz
}|�||���ddd��dS#1swxYwYdS)Nrr�zHunindent does not match any outer indentation level (<tokenize>, line 3)�rK�rrpr�)rr%rKs   r�test_with_errored_filez&TestCommandLine.test_with_errored_file3s���F�
�\�*:�;�
<�
<�	8�	�"�;�;�;�F��,�
-�F����i���7�7�7�		8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8�	8����	8�	8�	8�	8�	8�	8s�"A�A�Ac��	ttd��5}|�|��ddd��dS#1swxYwYdSrnr�rqs  r�test_with_error_free_filez)TestCommandLine.test_with_error_free_file;s���O�
�\�,�7�
8�
8�	)�I����i�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)rsc�^�	td��}d|�d�}|�|���dS)Nztabnanny.pyzUsage: z [-v] file_or_directory ...r�)rr�)rr�rKs   r�test_command_usagez"TestCommandLine.test_command_usage@s?��3��
�&�&��<�4�<�<�<�������(�(�(�(�(rc��	ttd��5}|�d�}|�d||���ddd��dS#1swxYwYdS)NrrFz-q)rkr�)rr%rks   r�test_quiet_flagzTestCommandLine.test_quiet_flagFs���8�
�\�*<�=�
>�
>�	>�)�!�%�%�%�F����d�I�f��=�=�=�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>����	>�	>�	>�	>�	>�	>s�A�A�Ac���	ttd��5}tjd�����}|�d||d���ddd��dS#1swxYwYdS)Nr�$offending line: '\tprint("world")\n'z-vT�rkr��rrp�textwrap�dedent�stripr��rr�rks   r�test_verbose_modez!TestCommandLine.test_verbose_modeLs���J�
�\�*<�=�
>�
>�	G�$��_�:����e�g�g�
�
���d�D����F�F�F�		G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G�	G����	G�	G�	G�	G�	G�	G��AA)�)A-�0A-c���	ttd��5}tjd�����}|�d||d���ddd��dS#1swxYwYdS)Nrr�z-vvTr�r�r�s   r�test_double_verbose_modez(TestCommandLine.test_double_verbose_modeTs���P�
�\�*<�=�
>�
>�	H�$��_�:����e�g�g�
�
���e�T�&�$��G�G�G�		H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H�	H����	H�	H�	H�	H�	H�	Hr�N)
r-r.r/r�r�r�r�r�r�r�r0rrr�r�s�������5�)+�B��H�H�H�H�H�"8�8�8�)�)�)�
)�)�)�>�>�>�G�G�G�H�H�H�H�Hrr�)�unittestrrr�r�r:r�r!r��test.supportrrrr�test.support.os_helperr	rprr2r?rNr`r�r�r0rr�<module>r�s���
$�#�#�#�#�#�#�#�����	�	�	�	�����������������$�$�$�$�$�$�$�$�$�$�$�$�)�)�)�)�)�)�
	�	%�	%�	%�	!�	'�K*�*��Z��������&M�M�M�M�M�(�M�M�M�"?�?�?�?�?�8�?�?�?�&9�9�9�9�9�8�9�9�9�6m=�m=�m=�m=�m=��m=�m=�m=�`<�<�<�<�<��<�<�<�<;H�;H�;H�;H�;H�h�;H�;H�;H�;H�;Hr