Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_tabnanny.cpython-39.opt-1.pyc

a

��g�5�@s�dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZmZddddd	d
d�ZGdd
�d
�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)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@s*eZdZdZd
dd�Zdd�Zdd	�ZdS)�TemporaryPyFilez+Create a temporary python source code file.�NcCs||_||_dS�N)�source_code�dir)�selfr�	directory�r�./usr/local/lib/python3.9/test/test_tabnanny.py�__init__AszTemporaryPyFile.__init__cCsNtjd|jddd��}|�|j�Wd�n1s60Y|j|_|jS)N�wz.pyF)�moder�suffix�delete)�tempfile�NamedTemporaryFiler�writer�name�	file_path)r�frrr�	__enter__Es
�*zTemporaryPyFile.__enter__cCst|j�dSr)rr!)r�exc_type�	exc_value�
exc_tracebackrrr�__exit__MszTemporaryPyFile.__exit__)rN)�__name__�
__module__�__qualname__�__doc__rr#r'rrrrr>s
rc@seZdZdZdd�ZdS)�TestFormatWitnessesz&Testing `tabnanny.format_witnesses()`.c	CsZgd�}|D]H\}}|j||d��"|�t�|�|�Wd�q1sJ0YqdS)z;Asserting formatter result by giving various input samples.))ZTestzat tab sizes T, e, s, t)rzat tab size )�tz
at tab size t)z  t  zat tab sizes  ,  , t,  ,  )�words�expectedN)�subTest�assertEqual�tabnannyZformat_witnesses)r�testsr.r/rrr�test_format_witnessesTsz)TestFormatWitnesses.test_format_witnessesN)r(r)r*r+r4rrrrr,Qsr,c@seZdZdZdd�ZdS)�TestErrPrintzTesting `tabnanny.errprint()`.c
Cs�ddgdfdgdfgd�dfgdfg}|D]v\}}|j||d��Pt��}tj|�Wd	�n1sh0Y|�|��|�Wd	�q*1s�0Yq*d	S)
zBAsserting result of `tabnanny.errprint()` by giving sample inputs.�first�secondz
first second
zfirst
)���z1 2 3
�
)Z	argumentsr/N)r0rr2Zerrprintr1�getvalue)rr3�argsr/�stderrrrr�
test_errprintes

�(zTestErrPrint.test_errprintN)r(r)r*r+r?rrrrr5bsr5c@seZdZdd�ZdS)�TestNannyNagc	Cs&t�ddd�dddd�ft�ddd�dddd�fg}|D]�\}}|��}|��}|��}|j||dd	�� |�|d|�Wd
�n1s�0Y|j||dd�� |�|d|�Wd
�n1s�0Y|j||d
d�� |�|d
|�Wd
�q81�s0Yq8d
S)z5Asserting behaviour of `tabnanny.NannyNag` exception.rZfooZbar)�lineno�msg�line�ZtestmsgZtestlinerA)�line_numberr/NrB)rBr/rC)rCr/)r2�NannyNagZ
get_linenoZget_msgZget_liner0r1)rr3Znannyr/rErBrCrrr�test_all_methodsvs&
�
��
�..zTestNannyNag.test_all_methodsN)r(r)r*rGrrrrr@usr@c@sjeZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�	TestCheckzTesting tabnanny.check().cCs|�ttdtj�dt_dS)N�verboser)Z
addCleanup�setattrr2rI)rrrr�setUp�szTestCheck.setUprc	Cszt��@}t��}t�|�Wd�n1s.0YWd�n1sL0Y|�|��|�|�|��|�dS)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)rrr2�checkr1r<)rZdir_or_file�out�err�stdoutr>rrr�verify_tabnanny_check�sFzTestCheck.verify_tabnanny_checkcCs:ttd��}|�|�Wd�n1s,0YdS)z-A python source code file without any errors.rN�r�SOURCE_CODESrP�rr!rrr�test_correct_file�szTestCheck.test_correct_filecCs~t����^}|�d�g}ttd|d�}ttd|d�}|��
}|��}||fD]}|�|�d��qNdt_t��@}t��}	t�	|�Wd�n1s�0YWd�n1s�0Y|�
�}|D]<}
|j|
d��|�|
|�Wd�q�1s�0Yq�|�
|	�
�d�Wd�n1�s00YWd�n1�sP0YWd�n1�sp0YdS)	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.
r8N)rCr)r�TemporaryDirectoryrrR�appendr2rIrrrLr<r0�assertInr1)r�tmp_dir�linesZfile1Zfile2Z
file1_pathZ
file2_pathr!rOr>rCrrr�test_correct_directory_verbose�sF,z(TestCheck.test_correct_directory_verbosec	Csft���J}ttd|d��|�|�Wd�n1s:0YWd�n1sX0YdS)zADirectory which contains few error free python source code files.rrUN�rrVrrRrP)rrYrrr�test_correct_directory�s
z TestCheck.test_correct_directorycCsPttd��0}d}|�d|��}|j||d�Wd�n1sB0YdS)zBA python source code file eligible for raising `IndentationError`.r
�Iunindent does not match any outer indentation level (<tokenize>, line 3)
�: Indentation Error: �rNNrQ�rr!rNrrr�test_when_wrong_indented�sz"TestCheck.test_when_wrong_indentedcCsPttd��0}d}|�d|��}|j||d�Wd�n1sB0YdS)zEA python source code file eligible for raising 'tokenize.TokenError'.r	z(('EOF in multi-line statement', (7, 0))
z: Token Error: r`NrQrarrr�test_when_tokenize_tokenerror�sz'TestCheck.test_when_tokenize_tokenerrorcCs^ttd��>}|�d�}|d7}|d7}dt_|j||d�Wd�n1sP0YdS)z�A python source code file eligible for raising `tabnanny.NannyNag`.

        Tests will assert `stdout` after activating `tabnanny.verbose` mode.
        rz': *** Line 3: trouble in tab city! ***
z%offending line: '\tprint("world")\n'
z$indent not equal e.g. at tab size 1
r8�rMN)rrRr2rIrP�rr!rMrrr� test_when_nannynag_error_verbose�s
z*TestCheck.test_when_nannynag_error_verbosecCsHttd��(}|�d�}|j||d�Wd�n1s:0YdS)zCA python source code file eligible for raising `tabnanny.NannyNag`.rz 3 '\tprint("world")\n'
rdNrQrerrr�test_when_nannynag_error�s
z"TestCheck.test_when_nannynag_errorcCs<d}|�dtj�dt�tj��d|�d�}|j||d�dS)z6A python file which does not exist actually in system.z
no_file.pyz: I/O Error: [Errno z] z: r;r`N)�errno�ENOENT�os�strerrorrP)r�pathrNrrr�test_when_no_file�s
��zTestCheck.test_when_no_filec
Cs�t����}ttd|d�}ttd|d�}|�T}|�0}d}|�d|��}|j||d�Wd�n1sj0YWd�n1s�0YWd�n1s�0YdS)z?Directory containing wrongly indented python source code files.r
rUrr^r_r`Nr\)rrYZ
error_fileZ	code_fileZe_fileZc_filerNrrr�test_errored_directory�s
��z TestCheck.test_errored_directoryN)rr)r(r)r*r+rKrPrTr[r]rbrcrfrgrmrnrrrrrH�s


rHc@s*eZdZdZe�d�dd��Zdd�ZdS)�TestProcessTokensz$Testing `tabnanny.process_tokens()`.ztabnanny.NannyNagc	Csvttd��V}t|��"}t�t�|j��Wd�n1s>0Y|�|j	�Wd�n1sh0YdS)z=A python source code without any whitespace related problems.rN)
rrR�openr2�process_tokens�tokenize�generate_tokens�readlineZassertFalseZcalled)rZMockNannyNagr!r"rrr�test_with_correct_codes
0z(TestProcessTokens.test_with_correct_codecCs�dD]�}|j|d���tt|��z}t|��R}t�|j�}|�tj	��t�
|�Wd�n1sf0YWd�n1s�0YWd�n1s�0YWd�q1s�0YqdS)z>A python source code with whitespace related sampled problems.)r
r)�keyN)r0rrRrprrrsrtZassertRaisesr2rFrq)rrvr!r"�tokensrrr�test_with_errored_codes_sampless	
z1TestProcessTokens.test_with_errored_codes_samplesN)r(r)r*r+rZpatchrurxrrrrros
roc@sReZdZdZdddd�dd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dS)�TestCommandLinez+Tests command line interface of `tabnanny`.rF)rOr>�partialc
Gs�tjddg|�R�\}}}t�|�}t�|�}|r�||f||ffD]X\}}	|	��}
|��D]>}|j||
d��|�||
�Wd�qZ1s�0YqZqBn(|�|��|���|�|��|���dS)zBCommon function to assert the behaviour of command line interface.z-mr2)�std�outputN)rZassert_python_okrj�fsdecode�
splitlinesr0rXZassertListEqual)rrOr>rzr=�_rMrNr{r|Z_outputZ_stdrrr�validate_cmd!s

0zTestCommandLine.validate_cmdcCsPttd��0}|�d�}|d7}|j||d�Wd�n1sB0YdS)z8Should displays error when errored python file is given.r
r_zHunindent does not match any outer indentation level (<tokenize>, line 3)�r>N�rrRr�)rr!r>rrr�test_with_errored_file2s
z&TestCommandLine.test_with_errored_filecCs:ttd��}|�|�Wd�n1s,0YdS)zAShould not display anything if python file is correctly indented.rNr�rSrrr�test_with_error_free_file:sz)TestCommandLine.test_with_error_free_filecCs$td�}d|�d�}|j|d�dS)z%Should display usage on no arguments.ztabnanny.pyzUsage: z [-v] file_or_directory ...r�N)rr�)rrlr>rrr�test_command_usage?sz"TestCommandLine.test_command_usagecCsJttd��*}|�d�}|jd||d�Wd�n1s<0YdS)z*Should display less when quite mode is on.rr;z-q)rONr�)rr!rOrrr�test_quiet_flagEs
zTestCommandLine.test_quiet_flagcCsPttd��0}t�d���}|jd||dd�Wd�n1sB0YdS)z<Should display more error information if verbose mode is on.r�$offending line: '\tprint("world")\n'z-vT�rOrzN�rrR�textwrap�dedent�stripr��rrlrOrrr�test_verbose_modeKs
�z!TestCommandLine.test_verbose_modecCsPttd��0}t�d���}|jd||dd�Wd�n1sB0YdS)zBShould display detailed error information if double verbose is on.rr�z-vvTr�Nr�r�rrr�test_double_verbose_modeSs
�z(TestCommandLine.test_double_verbose_modeN)r(r)r*r+r�r�r�r�r�r�r�rrrrrysry)r+Zunittestrrrhrjr2rrrr�Ztest.supportrrrrrrRrr,r5r@rHroryrrrr�<module>s,�-p

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