Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_tabnanny.cpython-310.pyc
o

�9j�5�@s�dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZddlmZdddd	d
dd�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/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__�__doc__rr#r'rrrrr?s

rc@�eZdZdZdd�ZdS)�TestFormatWitnessesz&Testing `tabnanny.format_witnesses()`.c	CsZgd�}|D]$\}}|j||d��|�t�|�|�Wd�n1s%wYqdS)z;Asserting formatter result by giving various input samples.))�Testzat 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�tabnanny�format_witnesses)r�testsr0r1rrr�test_format_witnessesUs���z)TestFormatWitnesses.test_format_witnessesN)r(r)r*r+r7rrrrr-R�r-c@r,)�TestErrPrintzTesting `tabnanny.errprint()`.c
Cs�ddgdfdgdfgd�dfgdfg}|D];\}}|j||d��(t��
}tj|�Wd	�n1s4wY|�|��|�Wd	�n1sKwYqd	S)
zBAsserting result of `tabnanny.errprint()` by giving sample inputs.�first�secondz
first second
zfirst
)���z1 2 3
�
)�	argumentsr1N)r2rr4�errprintr3�getvalue)rr6�argsr1�stderrrrr�
test_errprintfs

�����zTestErrPrint.test_errprintN)r(r)r*r+rErrrrr9cr8r9c@seZdZdd�ZdS)�TestNannyNagc	Cs$t�ddd�dddd�ft�ddd�dddd�fg}|D]s\}}|��}|��}|��}|j||dd	��|�|d|�Wd
�n1sHwY|j||dd��|�|d|�Wd
�n1siwY|j||d
d��|�|d
|�Wd
�n1s�wYqd
S)z5Asserting behaviour of `tabnanny.NannyNag` exception.r�foo�bar)�lineno�msg�line��testmsg�testlinerI)�line_numberr1NrJ)rJr1rK)rKr1)r4�NannyNag�
get_lineno�get_msg�get_liner2r3)rr6�nannyr1rOrJrKrrr�test_all_methodsws0
�
��
������zTestNannyNag.test_all_methodsN)r(r)r*rUrrrrrFvsrFc@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)�
addCleanup�setattrr4rW)rrrr�setUp�s
zTestCheck.setUprc	Cszt�� }t��
}t�|�Wd�n1swYWd�n1s&wY|�|��|�|�|��|�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)rrr4�checkr3rB)r�dir_or_file�out�err�stdoutrDrrr�verify_tabnanny_check�s��zTestCheck.verify_tabnanny_checkcC�<ttd��}|�|�Wd�dS1swYdS)z-A python source code file without any errors.rN�r�SOURCE_CODESr`�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�n1sJwYWd�n1sYwY|�
�}|D]}
|j|
d��|�|
|�Wd�n1s}wYqd|�
|	�
�d�Wd�n1s�wYWd�n1s�wYWd�dSWd�dS1s�wYdS)	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.
r<N)rKr)r�TemporaryDirectoryrrc�appendr4rWrrr[rBr2�assertInr3)r�tmp_dir�lines�file1�file2�
file1_path�
file2_pathr!r_rDrKrrr�test_correct_directory_verbose�s4
�������"�z(TestCheck.test_correct_directory_verbosec	Csxt���.}ttd|d��
|�|�Wd�n1swYWd�dSWd�dS1s5wYdS)zADirectory which contains few error free python source code files.rrgN�rrhrrcr`)rrkrrr�test_correct_directory�s
��"�z TestCheck.test_correct_directorycC�Rttd��}d}|�d|��}|j||d�Wd�dS1s"wYdS)zBA python source code file eligible for raising `IndentationError`.r
�Iunindent does not match any outer indentation level (<tokenize>, line 3)
�: Indentation Error: �r^Nrb�rr!r^rrr�test_when_wrong_indented�s
"�z"TestCheck.test_when_wrong_indentedcCrt)zEA python source code file eligible for raising 'tokenize.TokenError'.r	z(('EOF in multi-line statement', (7, 0))
z: Token Error: rwNrbrxrrr�test_when_tokenize_tokenerror�s
"�z'TestCheck.test_when_tokenize_tokenerrorcCs`ttd�� }|�d�}|d7}|d7}dt_|j||d�Wd�dS1s)wYdS)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
r<�r]N)rrcr4rWr`�rr!r]rrr� test_when_nannynag_error_verbose�s
"�z*TestCheck.test_when_nannynag_error_verbosecCsJttd��}|�d�}|j||d�Wd�dS1swYdS)zCA python source code file eligible for raising `tabnanny.NannyNag`.rz 3 '\tprint("world")\n'
r{Nrbr|rrr�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?rwN)�errno�ENOENT�os�strerrorr`)r�pathr^rrr�test_when_no_file�s
��zTestCheck.test_when_no_filec
Cs�t���U}ttd|d�}ttd|d�}|�*}|�}d}|�d|��}|j||d�Wd�n1s5wYWd�n1sDwYWd�dSWd�dS1s\wYdS)z?Directory containing wrongly indented python source code files.r
rgrrurvrwNrr)rrk�
error_file�	code_file�e_file�c_filer^rrr�test_errored_directory�s"
�����"�z TestCheck.test_errored_directoryN)rr)r(r)r*r+rZr`rerqrsryrzr}r~r�r�rrrrrV�s


rVc@s*eZdZdZe�d�dd��Zdd�ZdS)�TestProcessTokensz$Testing `tabnanny.process_tokens()`.ztabnanny.NannyNagc	Csxttd��,}t|��}t�t�|j��Wd�n1swY|�|j	�Wd�dS1s5wYdS)z=A python source code without any whitespace related problems.rN)
rrc�openr4�process_tokens�tokenize�generate_tokens�readline�assertFalse�called)r�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�n1s3wYWd�n1sBwYWd�n1sQwYWd�n1s`wYqdS)z>A python source code with whitespace related sampled problems.)r
r)�keyN)r2rrcr�r�r�r��assertRaisesr4rPr�)rr�r!r"�tokensrrr�test_with_errored_codes_samples
s 	
���������z1TestProcessTokens.test_with_errored_codes_samplesN)r(r)r*r+r�patchr�r�rrrrr�s

r�c@sReZdZdZdddd�dd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dS)�TestCommandLinez+Tests command line interface of `tabnanny`.rF)r_rD�partialc
Gs�tjddg|�R�\}}}t�|�}t�|�}|rP||f||ffD],\}}	|	��}
|��D]}|j||
d��|�||
�Wd�n1sGwYq-q!dS|�|��|���|�|��|���dS)zBCommon function to assert the behaviour of command line interface.z-mr4)�std�outputN)r�assert_python_okr��fsdecode�
splitlinesr2rj�assertListEqual)rr_rDr�rC�_r]r^r�r��_output�_stdrrr�validate_cmd"s

����zTestCommandLine.validate_cmdcCsRttd��}|�d�}|d7}|j||d�Wd�dS1s"wYdS)z8Should displays error when errored python file is given.r
rvzHunindent does not match any outer indentation level (<tokenize>, line 3)�rDN�rrcr�)rr!rDrrr�test_with_errored_file3s

"�z&TestCommandLine.test_with_errored_filecCra)zAShould not display anything if python file is correctly indented.rNr�rdrrr�test_with_error_free_file;rfz)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�)rr�rDrrr�test_command_usage@sz"TestCommandLine.test_command_usagecCsLttd��}|�d�}|jd||d�Wd�dS1swYdS)z*Should display less when quite mode is on.rr?z-q)r_Nr�)rr!r_rrr�test_quiet_flagFs
"�zTestCommandLine.test_quiet_flagcC�Rttd��}t�d���}|jd||dd�Wd�dS1s"wYdS)z<Should display more error information if verbose mode is on.r�$offending line: '\tprint("world")\n'z-vT�r_r�N�rrc�textwrap�dedent�stripr��rr�r_rrr�test_verbose_modeL���"�z!TestCommandLine.test_verbose_modecCr�)zBShould display detailed error information if double verbose is on.rr�z-vvTr�Nr�r�rrr�test_double_verbose_modeTr�z(TestCommandLine.test_double_verbose_modeN)r(r)r*r+r�r�r�r�r�r�r�rrrrr�sr�)r+�unittestrrrr�r4r�rr��test.supportrrrr�test.support.os_helperrrcrr-r9rFrVr�r�rrrr�<module>s0�-p

Youez - 2016 - github.com/yon3zu
LinuXploit