Your IP : 216.73.216.52


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_tabnanny.cpython-39.opt-2.pyc

a

XC?h�5�@s�ddlmZmZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
mZdddddd	d
�ZGdd�d�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�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@s&eZdZd	dd�Zdd�Zdd�ZdS)
�TemporaryPyFile�NcCs||_||_dS�N)�source_code�dir)�selfr�	directory�r�7/opt/alt/python39/lib64/python3.9/test/test_tabnanny.py�__init__AszTemporaryPyFile.__init__cCsNtjd|jddd��}|�|j�Wd�n1s60Y|j|_|jS)N�wz.pyF)�moder�suffix�delete)�tempfileZNamedTemporaryFiler�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__rr"r&rrrrr>s
rc@seZdZdd�ZdS)�TestFormatWitnessesc	CsZgd�}|D]H\}}|j||d��"|�t�|�|�Wd�q1sJ0YqdS)N))ZTestzat 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�tabnannyZformat_witnesses)r�testsr,r-rrr�test_format_witnessesTsz)TestFormatWitnesses.test_format_witnessesN)r'r(r)r2rrrrr*Qsr*c@seZdZdd�ZdS)�TestErrPrintc
Cs�ddgdfdgdfgd�dfgdfg}|D]v\}}|j||d��Pt��}tj|�Wd�n1sh0Y|�|��|�Wd�q*1s�0Yq*dS)	N�first�secondz
first second
zfirst
)���z1 2 3
�
)Z	argumentsr-)r.rr0Zerrprintr/�getvalue)rr1�argsr-�stderrrrr�
test_errprintes

�(zTestErrPrint.test_errprintN)r'r(r)r=rrrrr3bsr3c@seZdZdd�ZdS)�TestNannyNagc	Cs&t�ddd�dddd�ft�ddd�dddd�fg}|D]�\}}|��}|��}|��}|j||dd	�� |�|d|�Wd�n1s�0Y|j||d
d�� |�|d
|�Wd�n1s�0Y|j||dd
�� |�|d|�Wd�q81�s0Yq8dS)NrZfooZbar)�lineno�msg�line�ZtestmsgZtestliner?)�line_numberr-r@)r@r-rA)rAr-)r0�NannyNagZ
get_linenoZget_msgZget_liner.r/)rr1Znannyr-rCr@rArrr�test_all_methodsvs&
�
��
�..zTestNannyNag.test_all_methodsN)r'r(r)rErrrrr>usr>c@sfeZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�	TestCheckcCs|�ttdtj�dt_dS)N�verboser)Z
addCleanup�setattrr0rG)rrrr�setUp�szTestCheck.setUprc	Cszt��@}t��}t�|�Wd�n1s.0YWd�n1sL0Y|�|��|�|�|��|�dSr)rrr0�checkr/r:)rZdir_or_file�out�err�stdoutr<rrr�verify_tabnanny_check�sFzTestCheck.verify_tabnanny_checkcCs:ttd��}|�|�Wd�n1s,0YdS�Nr�r�SOURCE_CODESrN�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)Nz: listing directory
r�rz: Clean bill of health.
r6)rAr)r�TemporaryDirectoryrrQ�appendr0rGrrrJr:r.�assertInr/)r�tmp_dir�linesZfile1Zfile2Z
file1_pathZ
file2_pathr rMr<rArrr�test_correct_directory_verbose�sF,z(TestCheck.test_correct_directory_verbosec	Csft���J}ttd|d��|�|�Wd�n1s:0YWd�n1sX0YdS)NrrT�rrUrrQrN)rrXrrr�test_correct_directory�s
z TestCheck.test_correct_directorycCsPttd��0}d}|�d|��}|j||d�Wd�n1sB0YdS)Nr
�Iunindent does not match any outer indentation level (<tokenize>, line 3)
�: Indentation Error: �rLrP�rr rLrrr�test_when_wrong_indented�sz"TestCheck.test_when_wrong_indentedcCsPttd��0}d}|�d|��}|j||d�Wd�n1sB0YdS)Nr	z(('EOF in multi-line statement', (7, 0))
z: Token Error: r_rPr`rrr�test_when_tokenize_tokenerror�sz'TestCheck.test_when_tokenize_tokenerrorcCs^ttd��>}|�d�}|d7}|d7}dt_|j||d�Wd�n1sP0YdS)Nrz': *** Line 3: trouble in tab city! ***
z%offending line: '\tprint("world")\n'
z$indent not equal e.g. at tab size 1
r6�rK)rrQr0rGrN�rr rKrrr� test_when_nannynag_error_verbose�s
z*TestCheck.test_when_nannynag_error_verbosecCsHttd��(}|�d�}|j||d�Wd�n1s:0YdS)Nrz 3 '\tprint("world")\n'
rcrPrdrrr�test_when_nannynag_error�s
z"TestCheck.test_when_nannynag_errorcCs<d}|�dtj�dt�tj��d|�d�}|j||d�dS)Nz
no_file.pyz: I/O Error: [Errno z] z: r9r_)�errnoZENOENT�os�strerrorrN)r�pathrLrrr�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)Nr
rTrr]r^r_r[)rrXZ
error_fileZ	code_fileZe_fileZc_filerLrrr�test_errored_directory�s
��z TestCheck.test_errored_directoryN)rr)r'r(r)rIrNrSrZr\rarbrerfrkrlrrrrrF�s


rFc@s&eZdZe�d�dd��Zdd�ZdS)�TestProcessTokensztabnanny.NannyNagc	Csvttd��V}t|��"}t�t�|j��Wd�n1s>0Y|�|j	�Wd�n1sh0YdSrO)
rrQ�openr0�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)N)r
r)�key)r.rrQrnrprqrrZassertRaisesr0rDro)rrtr r!�tokensrrr�test_with_errored_codes_sampless	
z1TestProcessTokens.test_with_errored_codes_samplesN)r'r(r)rZpatchrsrvrrrrrms
rmc@sNeZdZdddd�dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dS)�TestCommandLinerF)rMr<�partialc
Gs�tjddg|�R�\}}}t�|�}t�|�}|r�||f||ffD]X\}}	|	��}
|��D]>}|j||
d��|�||
�Wd�qZ1s�0YqZqBn(|�|��|���|�|��|���dS)Nz-mr0)�std�output)rZassert_python_okrh�fsdecode�
splitlinesr.rWZassertListEqual)rrMr<rxr;�_rKrLryrzZ_outputZ_stdrrr�validate_cmd!s

0zTestCommandLine.validate_cmdcCsPttd��0}|�d�}|d7}|j||d�Wd�n1sB0YdS)Nr
r^zHunindent does not match any outer indentation level (<tokenize>, line 3)�r<�rrQr~)rr r<rrr�test_with_errored_file2s
z&TestCommandLine.test_with_errored_filecCs:ttd��}|�|�Wd�n1s,0YdSrOr�rRrrr�test_with_error_free_file:sz)TestCommandLine.test_with_error_free_filecCs$td�}d|�d�}|j|d�dS)Nztabnanny.pyzUsage: z [-v] file_or_directory ...r)rr~)rrjr<rrr�test_command_usage?sz"TestCommandLine.test_command_usagecCsJttd��*}|�d�}|jd||d�Wd�n1s<0YdS)Nrr9z-q)rMr�)rr rMrrr�test_quiet_flagEs
zTestCommandLine.test_quiet_flagcCsPttd��0}t�d���}|jd||dd�Wd�n1sB0YdS)Nr�$offending line: '\tprint("world")\n'z-vT�rMrx�rrQ�textwrap�dedent�stripr~�rrjrMrrr�test_verbose_modeKs
�z!TestCommandLine.test_verbose_modecCsPttd��0}t�d���}|jd||dd�Wd�n1sB0YdS)Nrr�z-vvTr�r�r�rrr�test_double_verbose_modeSs
�z(TestCommandLine.test_double_verbose_modeN)
r'r(r)r~r�r�r�r�r�r�rrrrrwsrw)Zunittestrrrgrhr0rprr�Ztest.supportrrrrrrQrr*r3r>rFrmrwrrrr�<module>s*�-p