+
    Bi7                     "   R t ^ RIHtHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
HtHtHtHt ^ RIHt RRRRR	R
RRRRRR/t ! R R4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      tR# )zfTesting `tabnanny` module.

Glossary:
    * errored    : Whitespace related problems present in file.
)TestCasemockN)captured_stderrcaptured_stdoutscript_helperfindfile)unlinkincomplete_expressionzCfruits = [
    "Apple",
    "Orange",
    "Banana",

print(fruits)
wrong_indentedzLif True:
    print("hello")
  print("world")
else:
    print("else called")
nannynag_erroredzIif True:
 	print("hello")
	print("world")
else:
    print("else called")

error_freezNif True:
    print("hello")
    print("world")
else:
    print("else called")
tab_space_errored_1zGdef my_func():
	  print("hello world")
	  if True:
		print("If called")tab_space_errored_2zLdef my_func():
		print("Hello world")
		if True:
	        print("If called")c                   :   a  ] tR t^?t o RtRR ltR tR tRtV t	R# )TemporaryPyFilez+Create a temporary python source code file.Nc                    Wn         W n        R # N)source_codedir)selfr   	directorys   &&&)/usr/lib/python3.14/test/test_tabnanny.py__init__TemporaryPyFile.__init__B   s    &    c                   \         P                  ! R V P                  RRR7      ;_uu_ 4       pVP                  V P                  4       RRR4       XP
                  V n        V P                  #   + '       g   i     L-; i)wz.pyF)moder   suffixdeleteN)tempfileNamedTemporaryFiler   writer   name	file_path)r   fs   & r   	__enter__TemporaryPyFile.__enter__F   s^    (($((5
 
GGD$$%
 ~~
 
s   A..A>	c                0    \        V P                  4       R # r   )r   r$   )r   exc_type	exc_valueexc_tracebacks   &&&&r   __exit__TemporaryPyFile.__exit__N   s    t~~r   )r   r$   r   ) N)
__name__
__module____qualname____firstlineno____doc__r   r&   r,   __static_attributes____classdictcell____classdict__s   @r   r   r   ?   s     5 r   r   c                   *   a  ] tR t^Rt o RtR tRtV tR# )TestFormatWitnessesz&Testing `tabnanny.format_witnesses()`.c                    . ROpV FN  w  r#V P                  W#R7      ;_uu_ 4        V P                  \        P                  ! V4      V4       RRR4       KP  	  R#   + '       g   i     Ke  ; i)z;Asserting formatter result by giving various input samples.)wordsexpectedN))Testzat tab sizes T, e, s, t)r.   zat tab size )tzat tab size t)z  t  zat tab sizes  ,  , t,  ,  )subTestassertEqualtabnannyformat_witnesses)r   testsr;   r<   s   &   r   test_format_witnesses)TestFormatWitnesses.test_format_witnessesU   sU    
  %OEE==  !:!:5!A8L >=  %===s   'AA, N)r/   r0   r1   r2   r3   rD   r4   r5   r6   s   @r   r9   r9   R   s     0M Mr   r9   c                   *   a  ] tR t^ct o RtR tRtV tR# )TestErrPrintzTesting `tabnanny.errprint()`.c                   RR.R3R.R3. R	OR3. R3.pV F  w  r#V P                  W#R7      ;_uu_ 4        V P                  \        4      ;_uu_ 4        \        4       ;_uu_ 4       p\        P
                  ! V!   RRR4       V P                  XP                  4       V4       RRR4       RRR4       K  	  R#   + '       g   i     LF; i  + '       g   i     L1; i  + '       g   i     K  ; i)
zBAsserting result of `tabnanny.errprint()` by giving sample inputs.firstsecondzfirst second
zfirst
z1 2 3

)	argumentsr<   N)         )r?   assertRaises
SystemExitr   rA   errprintr@   getvalue)r   rC   argsr<   stderrs   &    r   test_errprintTestErrPrint.test_errprintf   s     x "23Y	"	"J	
 $ND@@&&z22(**f ))40 +$$V__%6B 3 A@ $ +* 32 A@@s;   CC&B9;(C#C9C	CCCC0rF   N)r/   r0   r1   r2   r3   rW   r4   r5   r6   s   @r   rH   rH   c   s     (C Cr   rH   c                   &   a  ] tR t^wt o R tRtV tR# )TestNannyNagc                   \         P                  ! ^ RR4      R^ RRRR/3\         P                  ! ^RR4      R^RRRR/3.pV F  w  r#VP                  4       pVP                  4       pVP	                  4       pV P                  WCR,          R7      ;_uu_ 4        V P                  VR,          V4       R	R	R	4       V P                  WSR,          R
7      ;_uu_ 4        V P                  VR,          V4       R	R	R	4       V P                  WcR,          R7      ;_uu_ 4        V P                  VR,          V4       R	R	R	4       EK  	  R	#   + '       g   i     L; i  + '       g   i     Lm; i  + '       g   i     EK=  ; i)z5Asserting behaviour of `tabnanny.NannyNag` exception.foobarlinenomsglinetestmsgtestline)line_numberr<   N)r_   r<   )r`   r<   )rA   NannyNag
get_linenoget_msgget_liner?   r@   )r   rC   nannyr<   rc   r_   r`   s   &      r   test_all_methodsTestNannyNag.test_all_methodsx   sL    !!!UE21eUFE:
 !!!Y
;1eY
C	
  %OE**,K--/C>>#D'82D      (!3[A #@@  %#6 A462BCC  &!148 DC  %  A@CCCs$   EEE.EE+.F rF   N)r/   r0   r1   r2   ri   r4   r5   r6   s   @r   rZ   rZ   w   s     9 9r   rZ   c                   j   a  ] tR t^t o RtR tRR ltR tR tR t	R t
R tR	 tR
 tR tR tRtV tR# )	TestCheckzTesting tabnanny.check().c                p    V P                  \        \        R \        P                  4       ^ \        n        R# )verboseN)
addCleanupsetattrrA   rn   )r   s   &r   setUpTestCheck.setUp   s"    9h6F6FGr   c           	     j   \        4       ;_uu_ 4       p\        4       ;_uu_ 4       p\        P                  ! V4       RRR4       RRR4       V P	                  XP                  4       V4       V P	                  XP                  4       V4       R#   + '       g   i     LZ; i  + '       g   i     Le; i)a*  Common 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)r   r   rA   checkr@   rT   )r   dir_or_fileouterrstdoutrV   s   &&&&  r   verify_tabnanny_checkTestCheck.verify_tabnanny_check   sk     &/*;*;vNN;' +<*C0*C0 +<*;s!   B"B	B"BB""B2	c                    \        \        R,          4      ;_uu_ 4       pV P                  V4       RRR4       R#   + '       g   i     R# ; i)z-A python source code file without any errors.r   Nr   SOURCE_CODESry   r   r$   s   & r   test_correct_fileTestCheck.test_correct_file   s1    \,788I&&y1 9888	   ;A	c                   \         P                  ! 4       ;_uu_ 4       pV: R2.p\        \        R,          VR7      p\        \        R,          VR7      pT;_uu_ 4       qT;_uu_ 4       pWV3 F  pVP	                  V: R24       K  	  ^\
        n        \        4       ;_uu_ 4       p\        4       ;_uu_ 4       p	\
        P                  ! V4       RRR4       RRR4       XP                  4       pV F7  p
V P                  V
R7      ;_uu_ 4        V P                  W4       RRR4       K9  	  V P                  X	P                  4       R4       RRR4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     K  ; i  + '       g   i     L\; i  + '       g   i     Lg; i  + '       g   i     R# ; i)zDirectory 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   r   z: Clean bill of health.
N)r`   r.   )r    TemporaryDirectoryr   r}   appendrA   rn   r   r   rt   rT   r?   assertInr@   )r   tmp_dirlinesfile1file2
file1_path
file2_pathr$   rx   rV   r`   s   &          r   test_correct_directory_verbose(TestCheck.test_correct_directory_verbose   sB    ((**g{"78:E#L$>'RE#L$>'RE*eez",!9ILLI=0I!JK ": $% $&&&/2C2CvNN7+ 3D&*!D400d3 10 "   !2B7 ',	 +* 3D2C&& 100 ',e	 +**s   AG 
F5	*=F"'E;:E(E;7F"F",F"F5	G(E83E;;FF"F	F""F2-F5	5G GG	c           	        \         P                  ! 4       ;_uu_ 4       p\        \        R,          VR7      ;_uu_ 4        V P	                  V4       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)zADirectory which contains few error free python source code files.r   r   N)r    r   r   r}   ry   )r   r   s   & r   test_correct_directory TestCheck.test_correct_directory   sT    ((**g l!;wOO**73 P +*OO +**s"   !A6A#	A6#A3.A66B	c           	     &   \        \        R,          4      ;_uu_ 4       pRpV: RV 2pV P                  \        4      ;_uu_ 4        V P	                  WR7       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)zBA python source code file eligible for raising `IndentationError`.r
   Iunindent does not match any outer indentation level (<tokenize>, line 3)
: Indentation Error: rw   Nr   r}   rQ   rR   ry   r   r$   rw   s   &  r   test_when_wrong_indented"TestCheck.test_when_wrong_indented   sq    \*:;<<	*CM!6se<C"":..**9*> /	 =< /.	 =<<#   (A?A,	A?,A<7A??B	c           	     &   \        \        R,          4      ;_uu_ 4       pRpV: RV 2pV P                  \        4      ;_uu_ 4        V P	                  WR7       RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)zEA python source code file eligible for raising 'tokenize.TokenError'.r	   z(('EOF in multi-line statement', (7, 0))
z: Token Error: r   Nr   r   s   &  r   test_when_tokenize_tokenerror'TestCheck.test_when_tokenize_tokenerror   sp    \*ABCCy=CM6C"":..**9*> / DC /. DCCr   c                    \        \        R,          4      ;_uu_ 4       pV: R2pVR,          pVR,          p^\        n        V P	                  WR7       RRR4       R#   + '       g   i     R# ; i)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")'
z3inconsistent use of tabs and spaces in indentation
rv   N)r   r}   rA   rn   ry   r   r$   rv   s   &  r    test_when_nannynag_error_verbose*TestCheck.test_when_nannynag_error_verbose   sb    
 \*<=>>)M!IJC<<CIIC H&&y&: ?>>>s   6AA0	c                    \        \        R,          4      ;_uu_ 4       pV R2pV P                  WR7       RRR4       R#   + '       g   i     R# ; i)zCA python source code file eligible for raising `tabnanny.NannyNag`.r   z 3 '\tprint("world")'
r   Nr|   r   s   &  r   test_when_nannynag_error"TestCheck.test_when_nannynag_error   sB    \*<=>>)K9:C&&y&: ?>>>s   AA	c                "   RpV: R\         P                   R\        P                  ! \         P                  4       RV: R2pV P	                  \
        4      ;_uu_ 4        V P                  WR7       RRR4       R#   + '       g   i     R# ; i)z6A python file which does not exist actually in system.z
no_file.pyz: I/O Error: [Errno z] z: rL   r   N)errnoENOENTosstrerrorrQ   rR   ry   )r   pathrw   s   &  r   test_when_no_fileTestCheck.test_when_no_file   sl    -ell^2U\\*+2dXR9z**&&t&5 +***s    A==B	c                   \         P                  ! 4       ;_uu_ 4       p\        \        R,          VR7      p\        \        R,          VR7      pT;_uu_ 4       qC;_uu_ 4       pRpV: RV 2pV P	                  \
        4      ;_uu_ 4        V P                  WR7       RRR4       RRR4       RRR4       RRR4       R#   + '       g   i     L*; i  + '       g   i     L5; i  + '       g   i     L@; i  + '       g   i     R# ; i)z?Directory containing wrongly indented python source code files.r
   r   r   r   r   r   N)r    r   r   r}   rQ   rR   ry   )r   r   
error_file	code_filee_filec_filerw   s   &      r   test_errored_directory TestCheck.test_errored_directory   s    ((**g(-.'J (\*gI vyyF6
"7u=&&z22..w.@ 3	 (1 +* 32	 (1y +**sS   ;C9
C&	#(CC C&C&	.C9 CCC#C&	&C61C99D
	rF   N)r.   r.   )r/   r0   r1   r2   r3   rq   ry   r   r   r   r   r   r   r   r   r   r4   r5   r6   s   @r   rl   rl      sF     #12
804??;;6A Ar   rl   c                   Z   a  ] tR tRt o Rt]P                  ! R4      R 4       tR tRt	V t
R# )TestProcessTokensi  z$Testing `tabnanny.process_tokens()`.ztabnanny.NannyNagc           	     x   \        \        R,          4      ;_uu_ 4       p\        V4      ;_uu_ 4       p\        P                  ! \
        P                  ! VP                  4      4       RRR4       V P                  VP                  4       RRR4       R#   + '       g   i     L5; i  + '       g   i     R# ; i)z=A python source code without any whitespace related problems.r   N)
r   r}   openrA   process_tokenstokenizegenerate_tokensreadlineassertFalsecalled)r   MockNannyNagr$   r%   s   &&  r   test_with_correct_code(TestProcessTokens.test_with_correct_code	  sq     \,788IiA''(@(@(LM !\001 98  988s"   B(5B	(#B(B% B((B9	c                L   R F  pV P                  VR7      ;_uu_ 4        \        \        V,          4      ;_uu_ 4       p\        V4      ;_uu_ 4       p\        P
                  ! VP                  4      pV P                  \        P                  4      ;_uu_ 4        \        P                  ! V4       RRR4       RRR4       RRR4       RRR4       K  	  R#   + '       g   i     L.; i  + '       g   i     L9; i  + '       g   i     LD; i  + '       g   i     EK   ; i)z>A python source code with whitespace related sampled problems.)keyN)r   r   )r?   r   r}   r   r   r   r   rQ   rA   rd   r   )r   r   r$   r%   tokenss   &    r   test_with_errored_codes_samples1TestProcessTokens.test_with_errored_codes_samples  s     BC#&&$\#%6779iA!)!9!9!**!E!..x/@/@AA$33F; B ) 8 '& B
 BA ) 87 '&&sS   DC>AC+C2C+:C>DC(#C++C;6C>>D	DD#rF   N)r/   r0   r1   r2   r3   r   patchr   r   r4   r5   r6   s   @r   r   r     s.     .	ZZ#$2 %2< <r   r   c                   b   a  ] tR tRt o RtRRRRRRRR/R	 ltR
 tR tR tR t	R t
R tRtV tR# )TestCommandLinei$  z+Tests command line interface of `tabnanny`.rx   r.   rV   partialFexpect_failurec          	        V'       d   \         P                  ! RR.VO5!  w  rgpM\         P                  ! RR.VO5!  w  rgp\        P                  ! V4      p\        P                  ! V4      pV'       dm   W3W(33 F`  w  rV
P                  4       pV	P                  4        F7  pV P                  WR7      ;_uu_ 4        V P                  W4       RRR4       K9  	  Kb  	  R# V P                  VP                  4       VP                  4       4       V P                  VP                  4       VP                  4       4       R#   + '       g   i     K  ; i)zBCommon function to assert the behaviour of command line interface.z-mrA   )stdoutputN)	r   assert_python_failureassert_python_okr   fsdecode
splitlinesr?   r   assertListEqual)r   rx   rV   r   r   rU   _rv   rw   r   r   _output_stds   &$$$$*       r   validate_cmdTestCommandLine.validate_cmd'  s   '==dJVQUVKAC'88zQDQKAC kk#kk#!'}= ++-NN,D$??d4 @? -  >   !163D3D3FG  !163D3D3FG	 @??s   >E 	 Ec                    \        \        R,          4      ;_uu_ 4       pV: R2pVR,          pV P                  WRR7       RRR4       R#   + '       g   i     R# ; i)z8Should displays error when errored python file is given.r
   r   zFunindent does not match any outer indentation level (<string>, line 3)TrV   r   Nr   r}   r   )r   r$   rV   s   &  r   test_with_errored_file&TestCommandLine.test_with_errored_file;  sS    \*:;<<	"%:;F - .FitL	 =<<<s   #AA	c                    \        \        R,          4      ;_uu_ 4       pV P                  V4       RRR4       R#   + '       g   i     R# ; i)zAShould not display anything if python file is correctly indented.r   Nr   r~   s   & r   test_with_error_free_file)TestCommandLine.test_with_error_free_fileC  s1    \,788Ii( 9888r   c                N    \        R4      pRV R2pV P                  VRR7       R# )z%Should display usage on no arguments.ztabnanny.pyzUsage: z [-v] file_or_directory ...Tr   N)r   r   )r   r   rV   s   &  r   test_command_usage"TestCommandLine.test_command_usageH  s.    &4& ;<=r   c                    \        \        R,          4      ;_uu_ 4       pV R2pV P                  RWR7       RRR4       R#   + '       g   i     R# ; i)z*Should display less when quite mode is on.r   rL   z-q)rx   Nr   )r   r$   rx   s   &  r   test_quiet_flagTestCommandLine.test_quiet_flagN  sC    \*<=>>)!{"%FdI= ?>>>s   AA	c           	         \        \        R,          4      ;_uu_ 4       p\        P                  ! R4      P	                  4       pV P                  RWRR7       RRR4       R#   + '       g   i     R# ; i)z<Should display more error information if verbose mode is on.r   "offending line: '\tprint("world")'z-vTrx   r   Nr   r}   textwrapdedentstripr   r   r   rx   s   &  r   test_verbose_mode!TestCommandLine.test_verbose_modeT  sV    \*<=>>$__7eg  dDF	 ?>>>   9A""A3	c           	         \        \        R,          4      ;_uu_ 4       p\        P                  ! R4      P	                  4       pV P                  RWRR7       RRR4       R#   + '       g   i     R# ; i)zBShould display detailed error information if double verbose is on.r   r   z-vvTr   Nr   r   s   &  r   test_double_verbose_mode(TestCommandLine.test_double_verbose_mode\  sV    \*<=>>$__7eg  eT$G	 ?>>>r   rF   N)r/   r0   r1   r2   r3   r   r   r   r   r   r   r   r4   r5   r6   s   @r   r   r   $  sV     5H HB H HV[ H(M)
>>GH Hr   r   )r3   unittestr   r   r   r   rA   r   r    r   test.supportr   r   r   r   test.support.os_helperr   r}   r   r9   rH   rZ   rl   r   r   rF   r   r   <module>r      s   
 $  	    $ $ ) 	 	% 	% 	% 	!
 	'K*Z &M( M"C8 C(98 96qA qAh< <<>Hh >Hr   