HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_tabnanny.cpython-310.opt-2.pyc
o

�i�5�@s�	ddlmZmZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
ddlmZddddd	d
d�ZGdd
�d
�ZGdd�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(eZdZ	d	dd�Zdd�Zdd�ZdS)
�TemporaryPyFile�NcCs||_||_dS�N)�source_code�dir)�selfr�	directory�r�//usr/local/lib/python3.10/test/test_tabnanny.py�__init__Bs
zTemporaryPyFile.__init__cCsNtjd|jddd��}|�|j�Wd�n1swY|j|_|jS)N�wz.pyF)�moder�suffix�delete)�tempfile�NamedTemporaryFiler�writer�name�	file_path)r�frrr�	__enter__Fs
��zTemporaryPyFile.__enter__cCst|j�dSr)rr!)r�exc_type�	exc_value�
exc_tracebackrrr�__exit__NszTemporaryPyFile.__exit__)rN)�__name__�
__module__�__qualname__rr#r'rrrrr?s

rc@�eZdZ	dd�ZdS)�TestFormatWitnessesc	Cs\	gd�}|D]$\}}|j||d��|�t�|�|�Wd�n1s&wYqdS)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_witnessesUs���z)TestFormatWitnesses.test_format_witnessesN)r(r)r*r4rrrrr,R�r,c@r+)�TestErrPrintc
Cs�	ddgdfdgdfgd�dfgdfg}|D];\}}|j||d��(t��
}tj|�Wd�n1s5wY|�|��|�Wd�n1sLwYqdS)	N�first�secondz
first second
zfirst
)���z1 2 3
�
)Z	argumentsr/)r0rr2Zerrprintr1�getvalue)rr3�argsr/�stderrrrr�
test_errprintfs

�����zTestErrPrint.test_errprintN)r(r)r*r@rrrrr6cr5r6c@seZdZdd�ZdS)�TestNannyNagc	Cs&	t�ddd�dddd�ft�ddd�dddd�fg}|D]s\}}|��}|��}|��}|j||dd	��|�|d|�Wd�n1sIwY|j||d
d��|�|d
|�Wd�n1sjwY|j||dd
��|�|d|�Wd�n1s�wYqdS)NrZfooZbar)�lineno�msg�line�ZtestmsgZtestlinerB)�line_numberr/rC)rCr/rD)rDr/)r2�NannyNagZ
get_linenoZget_msgZget_liner0r1)rr3Znannyr/rFrCrDrrr�test_all_methodsws2
�
��
������zTestNannyNag.test_all_methodsN)r(r)r*rHrrrrrAvsrAc@sheZdZ	dd�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�setattrr2rJ)rrrr�setUp�s
zTestCheck.setUprc	Cs|	t�� }t��
}t�|�Wd�n1swYWd�n1s'wY|�|��|�|�|��|�dSr)rrr2�checkr1r=)rZdir_or_file�out�err�stdoutr?rrr�verify_tabnanny_check�s��zTestCheck.verify_tabnanny_checkcC�>	ttd��}|�|�Wd�dS1swYdS�Nr�r�SOURCE_CODESrQ�rr!rrr�test_correct_file��"�zTestCheck.test_correct_filecCs�	t����}|�d�g}ttd|d�}ttd|d�}|��}|�r}||fD]
}|�|�d��q&dt_t�� }t��
}	t�	|�Wd�n1sKwYWd�n1sZwY|�
�}|D]}
|j|
d��|�|
|�Wd�n1s~wYqe|�
|	�
�d�Wd�n1s�wYWd�n1s�wYWd�dSWd�dS1s�wYdS)Nz: listing directory
r�rz: Clean bill of health.
r9)rDr)r�TemporaryDirectoryrrU�appendr2rJrrrMr=r0�assertInr1)r�tmp_dir�linesZfile1Zfile2Z
file1_pathZ
file2_pathr!rPr?rDrrr�test_correct_directory_verbose�s6
�������"�z(TestCheck.test_correct_directory_verbosec	Csz	t���.}ttd|d��
|�|�Wd�n1swYWd�dSWd�dS1s6wYdS)NrrY�rrZrrUrQ)rr]rrr�test_correct_directory�s
��"�z TestCheck.test_correct_directorycC�T	ttd��}d}|�d|��}|j||d�Wd�dS1s#wYdS)Nr
�Iunindent does not match any outer indentation level (<tokenize>, line 3)
�: Indentation Error: �rOrT�rr!rOrrr�test_when_wrong_indented�s"�z"TestCheck.test_when_wrong_indentedcCrb)Nr	z(('EOF in multi-line statement', (7, 0))
z: Token Error: rerTrfrrr�test_when_tokenize_tokenerror�s"�z'TestCheck.test_when_tokenize_tokenerrorcCsb	ttd�� }|�d�}|d7}|d7}dt_|j||d�Wd�dS1s*wYdS)Nrz': *** Line 3: trouble in tab city! ***
z%offending line: '\tprint("world")\n'
z$indent not equal e.g. at tab size 1
r9�rN)rrUr2rJrQ�rr!rNrrr� test_when_nannynag_error_verbose�s
"�z*TestCheck.test_when_nannynag_error_verbosecCsL	ttd��}|�d�}|j||d�Wd�dS1swYdS)Nrz 3 '\tprint("world")\n'
rirTrjrrr�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: r<re)�errno�ENOENT�os�strerrorrQ)r�pathrOrrr�test_when_no_file�s
��zTestCheck.test_when_no_filec
Cs�	t���U}ttd|d�}ttd|d�}|�*}|�}d}|�d|��}|j||d�Wd�n1s6wYWd�n1sEwYWd�dSWd�dS1s]wYdS)Nr
rYrrcrdrer`)rr]Z
error_fileZ	code_fileZe_fileZc_filerOrrr�test_errored_directory�s$
�����"�z TestCheck.test_errored_directoryN)rr)r(r)r*rLrQrWr_rargrhrkrlrrrsrrrrrI�s


rIc@s(eZdZ	e�d�dd��Zdd�ZdS)�TestProcessTokensztabnanny.NannyNagc	Csz	ttd��,}t|��}t�t�|j��Wd�n1s wY|�|j	�Wd�dS1s6wYdSrS)
rrU�openr2�process_tokens�tokenize�generate_tokens�readlineZassertFalseZcalled)rZMockNannyNagr!r"rrr�test_with_correct_codes
�"�z(TestProcessTokens.test_with_correct_codecCs�	dD]c}|j|d��Stt|��=}t|��)}t�|j�}|�tj	��
t�
|�Wd�n1s4wYWd�n1sCwYWd�n1sRwYWd�n1sawYqdS)N)r
r)�key)r0rrUrurwrxryZassertRaisesr2rGrv)rr{r!r"�tokensrrr�test_with_errored_codes_samples
s"
���������z1TestProcessTokens.test_with_errored_codes_samplesN)r(r)r*rZpatchrzr}rrrrrts

rtc@sPeZdZ	dddd�dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Z	dS)�TestCommandLinerF)rPr?�partialc
Gs�	tjddg|�R�\}}}t�|�}t�|�}|rQ||f||ffD],\}}	|	��}
|��D]}|j||
d��|�||
�Wd�n1sHwYq.q"dS|�|��|���|�|��|���dS)Nz-mr2)�std�output)rZassert_python_okro�fsdecode�
splitlinesr0r\ZassertListEqual)rrPr?rr>�_rNrOr�r�Z_outputZ_stdrrr�validate_cmd"s 

����zTestCommandLine.validate_cmdcCsT	ttd��}|�d�}|d7}|j||d�Wd�dS1s#wYdS)Nr
rdzHunindent does not match any outer indentation level (<tokenize>, line 3)�r?�rrUr�)rr!r?rrr�test_with_errored_file3s
"�z&TestCommandLine.test_with_errored_filecCrRrSr�rVrrr�test_with_error_free_file;rXz)TestCommandLine.test_with_error_free_filecCs&	td�}d|�d�}|j|d�dS)Nztabnanny.pyzUsage: z [-v] file_or_directory ...r�)rr�)rrqr?rrr�test_command_usage@sz"TestCommandLine.test_command_usagecCsN	ttd��}|�d�}|jd||d�Wd�dS1s wYdS)Nrr<z-q)rPr�)rr!rPrrr�test_quiet_flagFs

"�zTestCommandLine.test_quiet_flagcC�T	ttd��}t�d���}|jd||dd�Wd�dS1s#wYdS)Nr�$offending line: '\tprint("world")\n'z-vT�rPr�rrU�textwrap�dedent�stripr��rrqrPrrr�test_verbose_modeL���"�z!TestCommandLine.test_verbose_modecCr�)Nrr�z-vvTr�r�r�rrr�test_double_verbose_modeTr�z(TestCommandLine.test_double_verbose_modeN)
r(r)r*r�r�r�r�r�r�r�rrrrr~sr~)Zunittestrrrmror2rwrr�Ztest.supportrrrrZtest.support.os_helperrrUrr,r6rArIrtr~rrrr�<module>s0�-p