HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/__pycache__/test_tabnanny.cpython-312.opt-2.pyc
�

�h�e�7���	ddlmZmZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
ddlmZddddd	d
d�ZGd�d
�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Zy)�)�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�Zy)�TemporaryPyFileNc� �||_||_y�N)�source_code�dir)�selfr�	directorys   �9/opt/alt/python312/lib64/python3.12/test/test_tabnanny.py�__init__zTemporaryPyFile.__init__Bs��&������c���tjd|jdd��5}|j|j�ddd�j
|_|jS#1swY�&xYw)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.c�.�t|j�yr)r	r$)r�exc_type�	exc_value�
exc_tracebacks    r�__exit__zTemporaryPyFile.__exit__Ns���t�~�~�r)�N)�__name__�
__module__�__qualname__rr&r+�rrrr?s��5���rrc��eZdZ	d�Zy)�TestFormatWitnessesc��	gd�}|D]F\}}|j||��5|jtj|�|�ddd��Hy#1swY�SxYw)N))�Testzat tab sizes T, e, s, t)r,z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_witnessesUsm��I�
�� %�	M�O�E�8����E�H��=�
M�� � ��!:�!:�5�!A�8�L�
M�
M�	M�
M�
M�s�&A�A	N)r-r.r/r=r0rrr2r2Rs��0�Mrr2c��eZdZ	d�Zy)�TestErrPrintc	��	ddgdfdgdfgd�dfgdfg}|D]�\}}|j||��5|jt�5t�5}t	j
|�ddd�|j
j�|�ddd�ddd���y#1swY�<xYw#1swY� xYw#1swY��xYw)	N�first�secondz
first second
zfirst
)���z1 2 3
�
)�	argumentsr7)r8�assertRaises�
SystemExitrr:�errprintr9�getvalue)rr<�argsr7�stderrs     r�
test_errprintzTestErrPrint.test_errprintfs���P��x�
 �"2�3��Y�	�"�
�	�"�
��J�	
��$�	C�N�D�(�����x��@�
C��&�&�z�2�C�(�*�1�f� �)�)�4�0�1��$�$�V�_�_�%6��B�C�
C�
C�	C�1�1��C�C��
C�
C�s;�B7�B+�B	�$(B+�B7�B(
�$B+�+B4�0B7�7C	N)r-r.r/rNr0rrr?r?cs��(�Crr?c��eZdZd�Zy)�TestNannyNagc�n�	tjddd�dddd�ftjddd�dddd�fg}|D]�\}}|j�}|j�}|j	�}|j||d�	�5|j
|d|�ddd�|j||d
��5|j
|d
|�ddd�|j||d�
�5|j
|d|�ddd���y#1swY�txYw#1swY�LxYw#1swY��xYw)Nr�foo�bar)�lineno�msg�line��testmsg�testlinerT)�line_numberr7rU)rUr7rV)rVr7)r:�NannyNag�
get_lineno�get_msg�get_liner8r9)rr<�nannyr7rZrUrVs       r�test_all_methodszTestNannyNag.test_all_methodsxsZ��C��!�!�!�U�E�2��U�E�:�
�
�!�!�!�Y�
�;��Y�
�C�
�	
�� %�	9�O�E�8��*�*�,�K��-�-�/�C��>�>�#�D����'�(�8�2D���
B�� � ��(�!3�[�A�
B����#�����@�
7�� � ��%��#�6�
7����4�(�6�2B��C�
9�� � ��&�!1�4�8�
9�
9�	9�
B�
B��
7�
7��
9�
9�s$�
D�>D�2D+�D	�D(	�+D4	N)r-r.r/r`r0rrrPrPws��9rrPc�R�eZdZ	d�Zd
d�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
y)�	TestCheckc�n�|jttdtj�dt_y)N�verboser)�
addCleanup�setattrr:rd)rs r�setUpzTestCheck.setUp�s"�������9�h�6F�6F�G���rc�,�	t�5}t�5}tj|�ddd�ddd�|j	j�|�|j	j�|�y#1swY�RxYw#1swY�VxYwr)rrr:�checkr9rK)r�dir_or_file�out�err�stdoutrMs      r�verify_tabnanny_checkzTestCheck.verify_tabnanny_check�s|��	��
�	(�&�/�*;�	(�v��N�N�;�'�	(�	(�������*�C�0�������*�C�0�	(�	(��	(�	(�s!�B
�A>�B
�>B	�B
�
Bc�v�	ttd�5}|j|�ddd�y#1swYyxYw�Nr
�r�SOURCE_CODESrn�rr$s  r�test_correct_filezTestCheck.test_correct_file�s7��;�
�\�,�7�
8�	2�I��&�&�y�1�	2�	2�	2���/�8c
���	tj�5}|�d�g}ttd|��}ttd|��}|5}|5}||fD]}|j	|�d���dt
_t�5}t�5}	tj|�ddd�ddd�j�}|D]/}
|j|
��5|j|
|�ddd��1|j	j�d�ddd�ddd�ddd�y#1swY��xYw#1swY��xYw#1swY��xYw#1swY�>xYw#1swY�BxYw#1swYyxYw)Nz: listing directory
r
�rz: Clean bill of health.
rC)rVr,)r �TemporaryDirectoryrrr�appendr:rdrrrirKr8�assertInr9)r�tmp_dir�lines�file1�file2�
file1_path�
file2_pathr$rmrMrVs           r�test_correct_directory_verbosez(TestCheck.test_correct_directory_verbose�sy��	��
(�
(�
*�	8�g��{�"7�8�:�E�#�L��$>�'�R�E�#�L��$>�'�R�E��
8�*�e�
8�z�",�j�!9�L�I��L�L�I�=�0I�!J�K�L�$%�� �$�&�,�&�/�2C�,�v��N�N�7�+�,�,����*��!�4�D����4��0�4��
�
�d�F�3�4�4�4�� � ����!2�B�7�
8�
8�		8�	8�,�,��,�,��4�4��
8�
8��
8�
8��		8�	8�s��1E'�E�
3E�=D7	�D+�D7	�&/E�E�(*E�E�E'�+D4�0D7	�7E
�<E�E�E�E�E�E$	� E'�'E0c���	tj�5}ttd|��5|j	|�ddd�ddd�y#1swY�xYw#1swYyxYw)Nr
rw)r rxrrrrn)rr{s  r�test_correct_directoryz TestCheck.test_correct_directory�s_��O�
�
(�
(�
*�	4�g� ��l�!;�w�O�
4��*�*�7�3�
4�	4�	4�
4�
4��	4�	4�s!�A�A�A�A	�A�A#c���	ttd�5}d}|�d|��}|jt�5|j	||��ddd�ddd�y#1swY�xYw#1swYyxYw)Nr�Iunindent does not match any outer indentation level (<tokenize>, line 3)
�: Indentation Error: �rl�rrrrHrIrn�rr$rls   r�test_when_wrong_indentedz"TestCheck.test_when_wrong_indented�s}��P�
�\�*:�;�
<�	?�	�*�C��M�!6�s�e�<�C��"�"�:�.�
?��*�*�9�#�*�>�
?�		?�	?�
?�
?��		?�	?��"�A$�A�A$�A!	�A$�$A-c���	ttd�5}d}|�d|��}|jt�5|j	||��ddd�ddd�y#1swY�xYw#1swYyxYw)Nr
z(('EOF in multi-line statement', (7, 0))
�: Token Error: r�r�r�s   r�test_when_tokenize_tokenerrorz'TestCheck.test_when_tokenize_tokenerror�sz��S�
�\�*A�B�
C�	?�y�=�C��M����6�C��"�"�:�.�
?��*�*�9�#�*�>�
?�	?�	?�
?�
?��	?�	?�r�c��	ttd�5}|�d�}|dz
}|dz
}dt_|j	||��ddd�y#1swYyxYw)Nrz': *** Line 3: trouble in tab city! ***
z#offending line: '\tprint("world")'
z3inconsistent use of tabs and spaces in indentation
rC�rk)rrrr:rdrn�rr$rks   r� test_when_nannynag_error_verbosez*TestCheck.test_when_nannynag_error_verbose�sl��	��\�*<�=�
>�	;�)��M�!I�J�C��<�<�C��I�I�C� �H���&�&�y�c�&�:�
	;�	;�	;�s�.A�Ac��	ttd�5}|�d�}|j||��ddd�y#1swYyxYw)Nrz 3 '\tprint("world")'
r�rqr�s   r�test_when_nannynag_errorz"TestCheck.test_when_nannynag_error�sJ��Q�
�\�*<�=�
>�	;�)��K�9�:�C��&�&�y�c�&�:�	;�	;�	;�s�6�?c��	d}|�dtj�dtjtj��d|�d�}|j	t
�5|j
||��ddd�y#1swYyxYw)Nz
no_file.pyz: I/O Error: [Errno z] z: rFr�)�errno�ENOENT�os�strerrorrHrIrn)r�pathrls   r�test_when_no_filezTestCheck.test_when_no_file�st��D�����-�e�l�l�^�2����U�\�\�*�+�2�d�X�R�9��
�
�
�z�
*�	6��&�&�t��&�5�	6�	6�	6�s�A3�3A<c	��	tj�5}ttd|��}ttd|��}|5}|5}d}|�d|��}|j	t
�5|j
||��ddd�ddd�ddd�ddd�y#1swY�"xYw#1swY�&xYw#1swY�*xYw#1swYyxYw)Nrrwr
r�r�r�)r rxrrrrHrIrn)rr{�
error_file�	code_file�e_file�c_filerls       r�test_errored_directoryz TestCheck.test_errored_directory�s���M�
�
(�
(�
*�	A�g�(��-�.�'��J�(��\�*�g��I��
A�v�y�
A�F�6���
�"7��u�=���&�&�z�2�A��.�.�w�C�.�@�A�	
A�
A�	A�	A�A�A��	
A�
A��
A�
A��	A�	A�sS�+B<�B0�B$�#B	�7B$�?B0�B<�B!
�B$�$B-�)B0�0B9	�5B<�<CN)r,r,)r-r.r/rgrnrtr�r�r�r�r�r�r�r�r0rrrbrb�s=��#��1�2�
8�04�?�?�;�;�6�Arrbc�D�eZdZ	ejd�d��Zd�Zy)�TestProcessTokensztabnanny.NannyNagc�.�	ttd�5}t|�5}tjtj|j��ddd�|j|j�ddd�y#1swY�-xYw#1swYyxYwrp)
rrr�openr:�process_tokens�tokenize�generate_tokens�readline�assertFalse�called)r�MockNannyNagr$r%s    r�test_with_correct_codez(TestProcessTokens.test_with_correct_code	s���K�
�\�,�7�
8�	2�I��i��
N�A��'�'��(@�(@����(L�M�
N����\�0�0�1�	2�	2�
N�
N��	2�	2�s"�B�3A?�#B�?B	�B�Bc
��	dD]�}|j|��5tt|�5}t|�5}t	j
|j�}|jtj�5tj|�ddd�ddd�ddd�ddd���y#1swY�$xYw#1swY�(xYw#1swY�,xYw#1swY��xYw)N)rr)�key)r8rrrr�r�r�r�rHr:r[r�)rr�r$r%�tokenss     r�test_with_errored_codes_samplesz1TestProcessTokens.test_with_errored_codes_sampless���L�B�	<�C����#��&�
<�$�\�#�%6�7�<�9��i��<�A�!)�!9�!9�!�*�*�!E��!�.�.�x�/@�/@�A�<�$�3�3�F�;�<�<�<�
<�
<�	<�
<�<��<�<��<�<��
<�
<�sQ�C�C�?B<	�7B0�
B<	�C�C�0B9�5B<	�<C
�C�C�
C�C	N)r-r.r/r�patchr�r�r0rrr�r�s(��.��T�Z�Z�#�$�2�%�2�<rr�c�D�eZdZ	ddddd�d�Zd�Zd�Zd�Zd�Zd	�Zd
�Z	y)�TestCommandLiner,F)rmrM�partial�expect_failurec�h�	|rtjddg|���\}}}ntjddg|���\}}}tj|�}tj|�}|rd||f||ffD]X\}	}
|
j�}|	j�D]0}|j
||��5|j||�ddd��2�Zy|j|j�|j��|j|j�|j��y#1swY��xYw)Nz-mr:)�std�output)	r�assert_python_failure�assert_python_okr��fsdecode�
splitlinesr8rz�assertListEqual)
rrmrMr�r�rL�_rkrlr�r��_output�_stds
             r�validate_cmdzTestCommandLine.validate_cmd's"��P��'�=�=�d�J�V�QU�V�K�A�s�C�'�8�8��z�Q�D�Q�K�A�s�C��k�k�#����k�k�#����!'��
���}�=�
5���V� �+�+�-���N�N�,�5�D����$�w��?�5��
�
�d�G�4�5�5�5�
5�
� � ����!1�6�3D�3D�3F�G�� � ����!1�6�3D�3D�3F�G�	5�5�s�+D(�(D1c��	ttd�5}|�d�}|dz
}|j||d��ddd�y#1swYyxYw)Nrr�zFunindent does not match any outer indentation level (<string>, line 3)T�rMr��rrrr�)rr$rMs   r�test_with_errored_filez&TestCommandLine.test_with_errored_file;s^��F�
�\�*:�;�
<�	M�	�"�
�_�5�F��-�
.�F����i��t��L�		M�	M�	M�s	�<�Ac�v�	ttd�5}|j|�ddd�y#1swYyxYwrpr�rss  r�test_with_error_free_filez)TestCommandLine.test_with_error_free_fileCs7��O�
�\�,�7�
8�	)�I����i�(�	)�	)�	)�ruc�N�	td�}d|�d�}|j|d��y)Nztabnanny.pyzUsage: z [-v] file_or_directory ...Tr�)rr�)rr�rMs   r�test_command_usagez"TestCommandLine.test_command_usageHs1��3��
�&���4�&� ;�<��������=rc��	ttd�5}|�d�}|jd||��ddd�y#1swYyxYw)NrrFz-q)rmr�)rr$rms   r�test_quiet_flagzTestCommandLine.test_quiet_flagNsK��8�
�\�*<�=�
>�	>�)�!�{�"�%�F����d�I�f��=�	>�	>�	>�s	�7�Ac���	ttd�5}tjd�j	�}|jd||d��ddd�y#1swYyxYw)Nr�"offending line: '\tprint("world")'z-vT�rmr��rrr�textwrap�dedent�stripr��rr�rms   r�test_verbose_modez!TestCommandLine.test_verbose_modeTsb��J�
�\�*<�=�
>�	G�$��_�_�7���e�g�
�
���d�D����F�		G�	G�	G���9A�Ac���	ttd�5}tjd�j	�}|jd||d��ddd�y#1swYyxYw)Nrr�z-vvTr�r�r�s   r�test_double_verbose_modez(TestCommandLine.test_double_verbose_mode\sb��P�
�\�*<�=�
>�	H�$��_�_�7���e�g�
�
���e�T�&�$��G�		H�	H�	H�r�N)
r-r.r/r�r�r�r�r�r�r�r0rrr�r�$s6��5�)+�B��V[�H�(M�)�
>�>�G�Hrr�)�unittestrrr�r�r:r�r r��test.supportrrrr�test.support.os_helperr	rrrr2r?rPrbr�r�r0rr�<module>r�s����
$��	�����$�$�)�
	�	%�	%�	%�	!�	'�K*��Z��&M�(�M�"C�8�C�(9�8�9�6qA��qA�h<��<�<>H�h�>Hr