Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_tabnanny.cpython-312.opt-1.pyc

�

'Μg�7���dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZddlmZdddd	d
dd�ZGd
�d�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Zy)zfTesting `tabnanny` module.

Glossary:
    * errored    : Whitespace related problems present in file.
�)�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�$�eZdZdZdd�Zd�Zd�Zy)�TemporaryPyFilez+Create a temporary python source code file.Nc� �||_||_y�N)�source_code�dir)�selfr�	directorys   �//usr/local/lib/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__FsY��
�
(�
(��$�(�(�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__�__doc__rr&r+�rrrr?s��5���rrc��eZdZdZd�Zy)�TestFormatWitnessesz&Testing `tabnanny.format_witnesses()`.c��gd�}|D]F\}}|j||��5|jtj|�|�ddd��Hy#1swY�SxYw)z;Asserting formatter result by giving various input samples.))�Testzat tab sizes T, e, s, t)r,zat tab size )�tz
at tab size t)z  t  zat tab sizes  ,  , t,  ,  )�words�expectedN)�subTest�assertEqual�tabnanny�format_witnesses)r�testsr7r8s    r�test_format_witnessesz)TestFormatWitnesses.test_format_witnessesUsS��
�� %�O�E�8����E�H��=�� � ��!:�!:�5�!A�8�L�>�=� %�=�=�s�&A�A	N)r-r.r/r0r>r1rrr3r3Rs��0�Mrr3c��eZdZdZd�Zy)�TestErrPrintzTesting `tabnanny.errprint()`.c	��ddgdfdgdfgd�dfgdfg}|D]�\}}|j||��5|jt�5t�5}t	j
|�d	d	d	�|j
j�|�d	d	d	�d	d	d	���y	#1swY�<xYw#1swY� xYw#1swY��xYw)
zBAsserting result of `tabnanny.errprint()` by giving sample inputs.�first�secondz
first second
zfirst
)���z1 2 3
�
)�	argumentsr8N)r9�assertRaises�
SystemExitrr;�errprintr:�getvalue)rr=�argsr8�stderrs     r�
test_errprintzTestErrPrint.test_errprintfs����x�
 �"2�3��Y�	�"�
�	�"�
��J�	
��$�N�D�(�����x��@��&�&�z�2�(�*�f� �)�)�4�0�+��$�$�V�_�_�%6��B�3�A�@�$�+�*��3�2��A�@�s;�B6�B*�B	�#(B*�B6�B'
�#B*�*B3�/B6�6B?	N)r-r.r/r0rOr1rrr@r@cs��(�Crr@c��eZdZd�Zy)�TestNannyNagc�l�tjddd�dddd�ftjddd�dddd�fg}|D]�\}}|j�}|j�}|j	�}|j||d�	�5|j
|d|�d
d
d
�|j||d��5|j
|d|�d
d
d
�|j||d
��5|j
|d
|�d
d
d
���y
#1swY�txYw#1swY�LxYw#1swY��xYw)z5Asserting behaviour of `tabnanny.NannyNag` exception.r�foo�bar)�lineno�msg�line��testmsg�testlinerU)�line_numberr8NrV)rVr8rW)rWr8)r;�NannyNag�
get_lineno�get_msg�get_liner9r:)rr=�nannyr8r[rVrWs       r�test_all_methodszTestNannyNag.test_all_methodsxs:���!�!�!�U�E�2��U�E�:�
�
�!�!�!�Y�
�;��Y�
�C�
�	
�� %�O�E�8��*�*�,�K��-�-�/�C��>�>�#�D����'�(�8�2D���� � ��(�!3�[�A�����#�����@�� � ��%��#�6�A����4�(�6�2B��C�� � ��&�!1�4�8�D�C� %����A�@��C�C�s$�	D�=D�1D*�D	�D'	�*D3	N)r-r.r/rar1rrrQrQws��9rrQc�T�eZdZdZd�Zdd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�	TestCheckzTesting tabnanny.check().c�n�|jttdtj�dt_y)N�verboser)�
addCleanup�setattrr;re)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�VxYw)aRCommon verification for tabnanny.check().

        Use this method to assert expected values of `stdout` and `stderr` after
        running tabnanny.check() on given `dir` or `file` path. Because
        tabnanny.check() captures exceptions and writes to `stdout` and
        `stderr`, asserting standard outputs is the only way.
        N)rrr;�checkr:rL)r�dir_or_file�out�err�stdoutrNs      r�verify_tabnanny_checkzTestCheck.verify_tabnanny_check�se���
�&�/�*;�v��N�N�;�'�+<�
�������*�C�0�������*�C�0�+<�*;��
�
�s!�B	�A=�B	�=B	�B	�	Bc�t�ttd�5}|j|�ddd�y#1swYyxYw)z-A python source code file without any errors.r
N�r�SOURCE_CODESro�rr$s  r�test_correct_filezTestCheck.test_correct_file�s+��
�\�,�7�
8�I��&�&�y�1�9�
8�
8���.�7c
���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)	aDirectory containing few error free python source code files.

        Because order of files returned by `os.lsdir()` is not fixed, verify the
        existence of each output lines at `stdout` using `in` operator.
        `verbose` mode of `tabnanny.verbose` asserts `stdout`.
        z: listing directory
r
�rz: Clean bill of health.
rDN)rWr,)r �TemporaryDirectoryrrr�appendr;rerrrjrLr9�assertInr:)r�tmp_dir�lines�file1�file2�
file1_path�
file2_pathr$rnrNrWs           r�test_correct_directory_verbosez(TestCheck.test_correct_directory_verbose�s0���
(�
(�
*�g��{�"7�8�:�E�#�L��$>�'�R�E�#�L��$>�'�R�E��*�e�z�",�j�!9�I��L�L�I�=�0I�!J�K�":�$%�� �$�&�&�/�2C�v��N�N�7�+�3D�&����*��!�D����4��0��
�
�d�F�3�1�0�"�� � ����!2�B�7�',��	+�
*�3D�2C��&�&��1�0��',�e�����	+�
*�s��1E&�E�	3E�<D6	�D*�D6	�%/E�E�'*E�E�E&�*D3�/D6	�6D?
�;E�E�E�E�E�E#	�E&�&E/c���tj�5}ttd|��5|j	|�ddd�ddd�y#1swY�xYw#1swYyxYw)zADirectory which contains few error free python source code files.r
rwN)r rxrrrro)rr{s  r�test_correct_directoryz TestCheck.test_correct_directory�sK��
�
(�
(�
*�g� ��l�!;�w�O��*�*�7�3�P�+�
*�O�O��+�
*�s!�A�A
�A�
A	�A�A"c���ttd�5}d}|�d|��}|jt�5|j	||��ddd�ddd�y#1swY�xYw#1swYyxYw)zBA python source code file eligible for raising `IndentationError`.r�Iunindent does not match any outer indentation level (<tokenize>, line 3)
�: Indentation Error: �rmN�rrrrIrJro�rr$rms   r�test_when_wrong_indentedz"TestCheck.test_when_wrong_indented�sj��
�\�*:�;�
<�	�*�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)zEA python source code file eligible for raising 'tokenize.TokenError'.r
z(('EOF in multi-line statement', (7, 0))
z: Token Error: r�Nr�r�s   r�test_when_tokenize_tokenerrorz'TestCheck.test_when_tokenize_tokenerror�si��
�\�*A�B�
C�y�=�C��M����6�C��"�"�:�.��*�*�9�#�*�>�/�D�
C�/�.��D�
C�r�c��ttd�5}|�d�}|dz
}|dz
}dt_|j	||��ddd�y#1swYyxYw)z�A python source code file eligible for raising `tabnanny.NannyNag`.

        Tests will assert `stdout` after activating `tabnanny.verbose` mode.
        rz': *** Line 3: trouble in tab city! ***
z#offending line: '\tprint("world")'
z3inconsistent use of tabs and spaces in indentation
rD�rlN)rrrr;rero�rr$rls   r� test_when_nannynag_error_verbosez*TestCheck.test_when_nannynag_error_verbose�s^��
�\�*<�=�
>�)��M�!I�J�C��<�<�C��I�I�C� �H���&�&�y�c�&�:�
?�
>�
>�s�.A
�
Ac��ttd�5}|�d�}|j||��ddd�y#1swYyxYw)zCA python source code file eligible for raising `tabnanny.NannyNag`.rz 3 '\tprint("world")'
r�Nrqr�s   r�test_when_nannynag_errorz"TestCheck.test_when_nannynag_error�s>��
�\�*<�=�
>�)��K�9�:�C��&�&�y�c�&�:�?�
>�
>�s�5�>c��d}|�dtj�dtjtj��d|�d�}|j	t
�5|j
||��ddd�y#1swYyxYw)z6A python file which does not exist actually in system.z
no_file.pyz: I/O Error: [Errno z] z: rGr�N)�errno�ENOENT�os�strerrorrIrJro)r�pathrms   r�test_when_no_filezTestCheck.test_when_no_file�sh������-�e�l�l�^�2����U�\�\�*�+�2�d�X�R�9��
�
�
�z�
*��&�&�t��&�5�+�
*�
*�s�A2�2A;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)z?Directory containing wrongly indented python source code files.rrwr
r�r�r�N)r rxrrrrIrJro)rr{�
error_file�	code_file�e_file�c_filerms       r�test_errored_directoryz TestCheck.test_errored_directory�s���
�
(�
(�
*�g�(��-�.�'��J�(��\�*�g��I��v�y�F�6���
�"7��u�=���&�&�z�2��.�.�w�C�.�@�3�	(1��+�
*�3�2��	(1�y�����+�
*�sS�+B;�B/�B#�"B	�6B#�>B/�B;�B 
�B#�#B,�(B/�/B8	�4B;�;CN)r,r,)r-r.r/r0rhrortr�r�r�r�r�r�r�r�r1rrrcrc�s=��#��1�2�
8�04�?�?�;�;�6�Arrcc�F�eZdZdZej
d�d��Zd�Zy)�TestProcessTokensz$Testing `tabnanny.process_tokens()`.ztabnanny.NannyNagc�,�ttd�5}t|�5}tjtj|j��ddd�|j|j�ddd�y#1swY�-xYw#1swYyxYw)z=A python source code without any whitespace related problems.r
N)
rrr�openr;�process_tokens�tokenize�generate_tokens�readline�assertFalse�called)r�MockNannyNagr$r%s    r�test_with_correct_codez(TestProcessTokens.test_with_correct_code	si���\�,�7�
8�I��i��A��'�'��(@�(@����(L�M�!����\�0�0�1�9�
8� ���9�
8�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)z>A python source code with whitespace related sampled problems.)rr)�keyN)r9rrrr�r�r�r�rIr;r\r�)rr�r$r%�tokenss     r�test_with_errored_codes_samplesz1TestProcessTokens.test_with_errored_codes_sampless���B�C����#��&�$�\�#�%6�7�9��i��A�!)�!9�!9�!�*�*�!E��!�.�.�x�/@�/@�A�$�3�3�F�;�B�)�8�'�&�B�
B�A��)���8�7��'�&�sQ�C�C�?B;	�6B/�B;	�C�C�/B8�4B;	�;C
�C�C�C�C	N)r-r.r/r0r�patchr�r�r1rrr�r�s(��.��T�Z�Z�#�$�2�%�2�<rr�c�F�eZdZdZddddd�d�Zd�Zd�Zd�Zd	�Zd
�Z	d�Z
y)
�TestCommandLinez+Tests command line interface of `tabnanny`.r,F)rnrN�partial�expect_failurec�f�|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)zBCommon function to assert the behaviour of command line interface.z-mr;)�std�outputN)	r�assert_python_failure�assert_python_okr��fsdecode�
splitlinesr9rz�assertListEqual)
rrnrNr�r�rM�_rlrmr�r��_output�_stds
             r�validate_cmdzTestCommandLine.validate_cmd's���'�=�=�d�J�V�QU�V�K�A�s�C�'�8�8��z�Q�D�Q�K�A�s�C��k�k�#����k�k�#����!'��
���}�=���V� �+�+�-���N�N�,�D����$�w��?��
�
�d�G�4�@�?�-� >�
� � ����!1�6�3D�3D�3F�G�� � ����!1�6�3D�3D�3F�G�	@�?�s�*D'�'D0c��ttd�5}|�d�}|dz
}|j||d��ddd�y#1swYyxYw)z8Should displays error when errored python file is given.rr�zFunindent does not match any outer indentation level (<string>, line 3)T�rNr�N�rrrr�)rr$rNs   r�test_with_errored_filez&TestCommandLine.test_with_errored_file;sO��
�\�*:�;�
<�	�"�
�%:�;�F��-�
.�F����i��t��L�	=�
<�
<�s	�;�Ac�t�ttd�5}|j|�ddd�y#1swYyxYw)zAShould not display anything if python file is correctly indented.r
Nr�rss  r�test_with_error_free_filez)TestCommandLine.test_with_error_free_fileCs+��
�\�,�7�
8�I����i�(�9�
8�
8�ruc�L�td�}d|�d�}|j|d��y)z%Should display usage on no arguments.ztabnanny.pyzUsage: z [-v] file_or_directory ...Tr�N)rr�)rr�rNs   r�test_command_usagez"TestCommandLine.test_command_usageHs.���
�&���4�&� ;�<��������=rc��ttd�5}|�d�}|jd||��ddd�y#1swYyxYw)z*Should display less when quite mode is on.rrGz-q)rnNr�)rr$rns   r�test_quiet_flagzTestCommandLine.test_quiet_flagNs?��
�\�*<�=�
>�)�!�{�"�%�F����d�I�f��=�?�
>�
>�s�6�?c���ttd�5}tjd�j	�}|jd||d��ddd�y#1swYyxYw)z<Should display more error information if verbose mode is on.r�"offending line: '\tprint("world")'z-vT�rnr�N�rrr�textwrap�dedent�stripr��rr�rns   r�test_verbose_modez!TestCommandLine.test_verbose_modeTsR��
�\�*<�=�
>�$��_�_�7���e�g�
�
���d�D����F�	?�
>�
>���9A�Ac���ttd�5}tjd�j	�}|jd||d��ddd�y#1swYyxYw)zBShould display detailed error information if double verbose is on.rr�z-vvTr�Nr�r�s   r�test_double_verbose_modez(TestCommandLine.test_double_verbose_mode\sR��
�\�*<�=�
>�$��_�_�7���e�g�
�
���e�T�&�$��G�	?�
>�
>�r�N)r-r.r/r0r�r�r�r�r�r�r�r1rrr�r�$s6��5�)+�B��V[�H�(M�)�
>�>�G�Hrr�)r0�unittestrrr�r�r;r�r r��test.supportrrrr�test.support.os_helperr	rrrr3r@rQrcr�r�r1rr�<module>r�s����
$��	�����$�$�)�
	�	%�	%�	%�	!�	'�K*��Z��&M�(�M�"C�8�C�(9�8�9�6qA��qA�h<��<�<>H�h�>Hr

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists