python (3.11.7)

(root)/
lib/
python3.11/
test/
__pycache__/
test_tabnanny.cpython-311.opt-1.pyc

e5BdZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZddlmZdddd	d
ddZGd
dZGddeZGddeZGddeZGddeZGddeZGddeZdS)zfTesting `tabnanny` module.

Glossary:
    * errored    : Whitespace related problems present in file.
)TestCasemockN)captured_stderrcaptured_stdout
script_helperfindfile)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_expressionwrong_indentednannynag_errored
error_freetab_space_errored_1tab_space_errored_2c&eZdZdZddZdZdZdS)TemporaryPyFilez+Create a temporary python source code file.Nc"||_||_dSN)source_codedir)selfr	directorys   F/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/test/test_tabnanny.py__init__zTemporaryPyFile.__init__Bs&ctjd|jdd5}||jdddn#1swxYwY|j|_|jS)Nwz.pyF)modersuffixdelete)tempfileNamedTemporaryFilerwritername	file_path)rfs  r	__enter__zTemporaryPyFile.__enter__Fs

($(5


	&

GGD$%%%	&	&	&	&	&	&	&	&	&	&	&	&	&	&	&~sAA	A	c.t|jdSr)r	r%)rexc_type	exc_value
exc_tracebacks    r__exit__zTemporaryPyFile.__exit__Nst~r)rN)__name__
__module____qualname____doc__rr'r,rrrr?sL55rrceZdZdZdZdS)TestFormatWitnessesz&Testing `tabnanny.format_witnesses()`.cgd}|D]\\}}|||5|tj||dddn#1swxYwY]dS)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,  ,  )wordsexpectedN)subTestassertEqualtabnannyformat_witnesses)rtestsr7r8s    rtest_format_witnessesz)TestFormatWitnesses.test_format_witnessesUs


 %	M	MOE8EH==
M
M  !:5!A!A8LLL
M
M
M
M
M
M
M
M
M
M
M
M
M
M
M	M	Ms)AA	A	N)r-r.r/r0r>r1rrr3r3Rs.00MMMMMrr3ceZdZdZdZdS)TestErrPrintzTesting `tabnanny.errprint()`.cRddgdfdgdfgddfgdfg}|D]\}}|||5t5}tj|d	d	d	n#1swxYwY|||d	d	d	n#1swxYwYd	S)
zBAsserting result of `tabnanny.errprint()` by giving sample inputs.firstsecondz
first second
zfirst
)z1 2 3

)	argumentsr8N)r9rr;errprintr:getvalue)rr=argsr8stderrs     r
test_errprintzTestErrPrint.test_errprintfsMx
 "23Y	"
YY	"
J	
$	?	?ND(x@@
?
?$&&-&%t,,---------------  !2!2X>>>
?
?
?
?
?
?
?
?
?
?
?
?
?
?
?	?	?s5BABA  B#A $+BB	"B	N)r-r.r/r0rMr1rrr@r@cs)((
?
?
?
?
?rr@ceZdZdZdS)TestNannyNagctjdddddddftjdddddddfg}|D]5\}}|}|}|}|||d	5||d|d
d
d
n#1swxYwY|||d5||d|d
d
d
n#1swxYwY|||d
5||d
|d
d
d
n#1swxYwY7d
S)z5Asserting behaviour of `tabnanny.NannyNag` exception.rfoobar)linenomsglinetestmsgtestlinerS)line_numberr8NrT)rTr8rU)rUr8)r;NannyNag
get_linenoget_msgget_liner9r:)rr=nannyr8rYrTrUs       rtest_all_methodszTestNannyNag.test_all_methodsws^!!UE22UE::

!!Y
;;Y
CC
	
 %	9	9OE8**,,K--//C>>##D'(82D
B
B  (!3[AAA
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B#@@
7
7  %#666
7
7
7
7
7
7
7
7
7
7
7
7
7
7
74(62BCC
9
9  &!14888
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9	9	9s6CC	
C	+DD	D	<E%%E)	,E)	N)r-r.r/r_r1rrrOrOvs#99999rrOcVeZdZdZdZddZdZdZdZdZ	d	Z
d
ZdZdZ
d
ZdS)	TestCheckzTesting tabnanny.check().cv|ttdtjdt_dS)Nverboser)
addCleanupsetattrr;rc)rs rsetUpzTestCheck.setUps+9h6FGGGrrcft5}t5}tj|dddn#1swxYwYdddn#1swxYwY||||||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)rrr;checkr:rJ)rdir_or_fileouterrstdoutrLs      rverify_tabnanny_checkzTestCheck.verify_tabnanny_checks

	(&/*;*;	(vN;'''	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(	(**C000**C00000s1A?AA	AA	AAActtd5}||ddddS#1swxYwYdS)z-A python source code file without any errors.r
NrSOURCE_CODESrmrr%s  rtest_correct_filezTestCheck.test_correct_files
\,7
8
8	2I&&y111	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2>AAc
btj5}|dg}ttd|}ttd|}|5}|5}||fD]}||ddt
_t5}t5}	tj	|dddn#1swxYwYdddn#1swxYwY|
}|D]F}
||
5||
|dddn#1swxYwYG|
|	
ddddn#1swxYwYdddn#1swxYwYddddS#1swxYwYdS)	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)rUr)r!TemporaryDirectoryrrpappendr;rcrrrhrJr9assertInr:)rtmp_dirlinesfile1file2
file1_path
file2_pathr%rlrLrUs           rtest_correct_directory_verbosez(TestCheck.test_correct_directory_verboses%
(
*
*	8g888:E#L$>'RRRE#L$>'RRRE
8*e
8z",j!9LLILLI!J!J!JKKKK#$ $&&,&/2C2C,vN7+++,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,**!44D40044

dF333444444444444444  !2!2B777
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8		8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8sAF$F:E5C	!C6C	CC		C
C	
E5C
E5 C
!1E5D5)E55D99E5<D9=,E5)F5E99F<E9=FF$F	F$F	F$$F(+F(ctj5}ttd|5||dddn#1swxYwYddddS#1swxYwYdS)zADirectory which contains few error free python source code files.r
ruNr!rvrrprm)rrys  rtest_correct_directoryz TestCheck.test_correct_directorys

(
*
*	4g l!;wOOO
4
4**7333
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4	4	4	4	4	4	4	4	4	4	4	4	4	4	4	4	4	4	4s4A+AA+A	A+A	A++A/2A/cttd5}d}|d|}|||ddddS#1swxYwYdS)zBA python source code file eligible for raising `IndentationError`.rIunindent does not match any outer indentation level (<tokenize>, line 3)
: Indentation Error: rkNrorr%rks   rtest_when_wrong_indentedz"TestCheck.test_when_wrong_indenteds
\*:;
<
<	;	*C<<s<<C&&yc&:::		;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;!A		A
A
cttd5}d}|d|}|||ddddS#1swxYwYdS)zEA python source code file eligible for raising 'tokenize.TokenError'.r
z(('EOF in multi-line statement', (7, 0))
z: Token Error: rNrors   rtest_when_tokenize_tokenerrorz'TestCheck.test_when_tokenize_tokenerrors
\*AB
C
C	;y=C6666C&&yc&:::	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;rcttd5}|d}|dz
}|dz
}dt_|||ddddS#1swxYwYdS)zA 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")\n'
z$indent not equal e.g. at tab size 1
rDrjN)rrpr;rcrmrr%rjs   r test_when_nannynag_error_verbosez*TestCheck.test_when_nannynag_error_verboses
\*<=
>
>	;)JJJC??C::C H&&yc&:::
	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;s3AA"Acttd5}|d}|||ddddS#1swxYwYdS)zCA python source code file eligible for raising `tabnanny.NannyNag`.rz 3 '\tprint("world")\n'
rNrors   rtest_when_nannynag_errorz"TestCheck.test_when_nannynag_errors
\*<=
>
>	;)===C&&yc&:::	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;	;sAA	A	cd}|dtjdtjtjd|d}|||dS)z6A python file which does not exist actually in system.z
no_file.pyz: I/O Error: [Errno z] z: rGrN)errnoENOENTosstrerrorrm)rpathrks   rtest_when_no_filezTestCheck.test_when_no_filesn99el99U\**99.2999""4S"11111rcvtj5}ttd|}ttd|}|5}|5}d}|d|}|||dddn#1swxYwYdddn#1swxYwYddddS#1swxYwYdS)z?Directory containing wrongly indented python source code files.rrur
rrrNr)rry
error_file	code_filee_filec_filerks       rtest_errored_directoryz TestCheck.test_errored_directorys

(
*
*	=g(-.'J(\*gI
=vy
=F6====**7*<<<	
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=	=sY;B.B!A?3B?BBBB
B.B	B.B	B..B25B2N)rr)r-r.r/r0rfrmrrrrrrrrrrr1rrraras##1111222
8880444;;;;;;;;;;;;222
=
=
=
=
=rracJeZdZdZejddZdZdS)TestProcessTokensz$Testing `tabnanny.process_tokens()`.ztabnanny.NannyNagcDttd5}t|5}tjtj|jdddn#1swxYwY||j	ddddS#1swxYwYdS)z=A python source code without any whitespace related problems.r
N)
rrpopenr;process_tokenstokenizegenerate_tokensreadlineassertFalsecalled)rMockNannyNagr%r&s    rtest_with_correct_codez(TestProcessTokens.test_with_correct_codes\,7
8
8	2Ii
NA'(@(L(LMMM
N
N
N
N
N
N
N
N
N
N
N
N
N
N
N\0111	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2	2s4B,A#B#A'	'B*A'	+BBBc
dD]}||5tt|5}t|5}t	j|j}|tj	5tj
|dddn#1swxYwYdddn#1swxYwYdddn#1swxYwYdddn#1swxYwYdS)z>A python source code with whitespace related sampled problems.)rr)keyN)r9rrprrrrassertRaisesr;rZr)rrr%r&tokenss     rtest_with_errored_codes_samplesz1TestProcessTokens.test_with_errored_codes_samples
sB	<	<C#&&
<
<$\#%677<9i<A!)!9!*!E!E!..x/@AA<<$3F;;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<	<	<s|C%C9B7	?B B7	 B$$B7	'B$(B7	+C7B;
;C>B;
?CC%CC%CC%%C)	,C)	N)r-r.r/r0rpatchrrr1rrrrsP..TZ#$$22%$2<<<<<rrcFeZdZdZdddddZdZdZdZd	Zd
Z	dZ
dS)
TestCommandLinez+Tests command line interface of `tabnanny`.rF)rlrLpartialcptjddg|R\}}}tj|}tj|}|r||f||ffD]u\}}	|	}
|D]G}|||
5|||
dddn#1swxYwYHvdS||||||dS)zBCommon function to assert the behaviour of command line interface.z-mr;)stdoutputN)rassert_python_okrfsdecode
splitlinesr9rxassertListEqual)rrlrLrrK_rjrkrr_output_stds            rvalidate_cmdzTestCommandLine.validate_cmd"s#4T:MMMM3k#k#	H!'
}=
5
5V ++--NN,,55D$w??55

dG4445555555555555555
5
5
  !1!163D3D3F3FGGG  !1!163D3D3F3FGGGGGsB33B7:B7cttd5}|d}|dz
}|||ddddS#1swxYwYdS)z8Should displays error when errored python file is given.rrzHunindent does not match any outer indentation level (<tokenize>, line 3)rLNrrpr)rr%rLs   rtest_with_errored_filez&TestCommandLine.test_with_errored_file3s
\*:;
<
<	8	";;;F,
-Fi777		8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8	8s"A

AActtd5}||ddddS#1swxYwYdS)zAShould not display anything if python file is correctly indented.r
Nrrqs  rtest_with_error_free_filez)TestCommandLine.test_with_error_free_file;s
\,7
8
8	)Ii(((	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)	)rsc\td}d|d}||dS)z%Should display usage on no arguments.ztabnanny.pyzUsage: z [-v] file_or_directory ...rN)rr)rrrLs   rtest_command_usagez"TestCommandLine.test_command_usage@s<
&&<4<<<(((((rcttd5}|d}|d||ddddS#1swxYwYdS)z*Should display less when quite mode is on.rrGz-q)rlNr)rr%rls   rtest_quiet_flagzTestCommandLine.test_quiet_flagFs
\*<=
>
>	>)!%%%FdIf===	>	>	>	>	>	>	>	>	>	>	>	>	>	>	>	>	>	>sAA

A
cttd5}tjd}|d||dddddS#1swxYwYdS)z<Should display more error information if verbose mode is on.r$offending line: '\tprint("world")\n'z-vTrlrNrrptextwrapdedentstriprrrrls   rtest_verbose_modez!TestCommandLine.test_verbose_modeLs
\*<=
>
>	G$_:egg

dDFFF		G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G	GAA((A,/A,cttd5}tjd}|d||dddddS#1swxYwYdS)zBShould display detailed error information if double verbose is on.rrz-vvTrNrrs   rtest_double_verbose_modez(TestCommandLine.test_double_verbose_modeTs
\*<=
>
>	H$_:egg

eT&$GGG		H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	H	HrN)r-r.r/r0rrrrrrrr1rrrrs55)+BHHHHH"888)))
)))>>>GGGHHHHHrr)r0unittestrrrrr;rr!rtest.supportrrrrtest.support.os_helperr	rprr3r@rOrarrr1rr<module>rs"
$#######				$$$$$$$$$$$$))))))
		%	%	%	!	'K**Z&MMMMM(MMM"?????8???&9999989996m=m=m=m=m=m=m=m=`<<<<<<<<<;H;H;H;H;Hh;H;H;H;H;Hr