
    z%i7                        	 d dl mZmZ d dlZd dlZd dlZd dlZd dlZd dlZd dl	m
Z
mZmZmZ d dlmZ ddddd	d
dZ G d d      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Zy)    )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                   "    e Zd Z	 ddZd Zd Zy)TemporaryPyFileNc                      || _         || _        y N)source_codedir)selfr   	directorys      F/home/uftp/.pyenv/versions/3.12.0/lib/python3.12/test/test_tabnanny.py__init__zTemporaryPyFile.__init__B   s    &    c                     t        j                  d| j                  dd      5 }|j                  | j                         d d d        j
                  | _        | j                  S # 1 sw Y   &xY w)Nwz.pyF)moder   suffixdelete)tempfileNamedTemporaryFiler   writer   name	file_path)r   fs     r   	__enter__zTemporaryPyFile.__enter__F   s^    (($((5
 	&GGD$$%	& ~~	& 	&s   A%%A.c                 .    t        | j                         y r   )r	   r$   )r   exc_type	exc_valueexc_tracebacks       r   __exit__zTemporaryPyFile.__exit__N   s    t~~r   ) N)__name__
__module____qualname__r   r&   r+    r   r   r   r   ?   s    5r   r   c                       e Zd Z	 d Zy)TestFormatWitnessesc                     	 g d}|D ]F  \  }}| j                  ||      5  | j                  t        j                  |      |       d d d        H y # 1 sw Y   SxY w)N))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,  ,  )wordsexpected)subTestassertEqualtabnannyformat_witnesses)r   testsr6   r7   s       r   test_format_witnessesz)TestFormatWitnesses.test_format_witnessesU   sm    I
  % 	MOE8EH= M  !:!:5!A8LM M	MM Ms   &AA	N)r-   r.   r/   r=   r0   r   r   r2   r2   R   s    0Mr   r2   c                       e Zd Z	 d Zy)TestErrPrintc           	         	 ddgdfdgdfg ddfg dfg}|D ]  \  }}| j                  ||      5  | j                  t              5  t               5 }t	        j
                  |  d d d        | j                  j                         |       d d d        d d d         y # 1 sw Y   <xY w# 1 sw Y    xY w# 1 sw Y   xY w)	Nfirstsecondzfirst second
zfirst
)         z1 2 3

)	argumentsr7   )r8   assertRaises
SystemExitr   r:   errprintr9   getvalue)r   r<   argsr7   stderrs        r   test_errprintzTestErrPrint.test_errprintf   s    Px "23Y	"	"J	
 $ 	CND(x@ C&&z2 C(* 1f ))401$$V__%6BCC C	C1 1C CC Cs;   B7B+B	$(B+B7B($B++B40B77C 	N)r-   r.   r/   rN   r0   r   r   r?   r?   c   s    (Cr   r?   c                       e Zd Zd Zy)TestNannyNagc                 n   	 t        j                  ddd      ddddft        j                  ddd      ddddfg}|D ]  \  }}|j                         }|j                         }|j	                         }| j                  ||d   	      5  | j                  |d   |       d d d        | j                  ||d
         5  | j                  |d
   |       d d d        | j                  ||d         5  | j                  |d   |       d d d         y # 1 sw Y   txY w# 1 sw Y   LxY w# 1 sw Y   xY w)Nr   foobar)linenomsgline   testmsgtestlinerT   )line_numberr7   rU   )rU   r7   rV   )rV   r7   )r:   NannyNag
get_linenoget_msgget_liner8   r9   )r   r<   nannyr7   rZ   rU   rV   s          r   test_all_methodszTestNannyNag.test_all_methodsx   sZ   C !!!UE2UE:
 !!!Y
;Y
C	
  % 	9OE8**,K--/C>>#D'(82D   B   (!3[AB #@ 7  %#674(62BC 9  &!1489 9	9B B7 79 9s$   
D>D2D+D	D(	+D4	N)r-   r.   r/   r`   r0   r   r   rP   rP   w   s    9r   rP   c                   R    e Zd Z	 d ZddZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zy)	TestCheckc                 n    | j                  t        t        dt        j                         dt        _        y )Nverboser   )
addCleanupsetattrr:   rd   )r   s    r   setUpzTestCheck.setUp   s"    9h6F6FGr   c                 ,   	 t               5 }t               5 }t        j                  |       d d d        d d d        | j	                  j                         |       | j	                  j                         |       y # 1 sw Y   RxY w# 1 sw Y   VxY wr   )r   r   r:   checkr9   rK   )r   dir_or_fileouterrstdoutrM   s         r   verify_tabnanny_checkzTestCheck.verify_tabnanny_check   s|    	  	(&/*; 	(vNN;'	( 	(*C0*C0	( 	( 	( 	(s!   B
A>B
>B	B

Bc                 v    	 t        t        d         5 }| j                  |       d d d        y # 1 sw Y   y xY wNr   r   SOURCE_CODESrn   r   r$   s     r   test_correct_filezTestCheck.test_correct_file   s7    ;\,78 	2I&&y1	2 	2 	2   /8c           
         	 t        j                         5 }|dg}t        t        d   |      }t        t        d   |      }|5 }|5 }||fD ]  }|j	                  |d        dt
        _        t               5 }t               5 }	t        j                  |       d d d        d d d        j                         }|D ]/  }
| j                  |
      5  | j                  |
|       d d d        1 | j                  	j                         d       d d d        d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   >xY w# 1 sw Y   BxY w# 1 sw Y   y xY w)Nz: listing directory
r   r   z: Clean bill of health.
rC   )rV   r,   )r    TemporaryDirectoryr   rr   appendr:   rd   r   r   ri   rK   r8   assertInr9   )r   tmp_dirlinesfile1file2
file1_path
file2_pathr$   rm   rM   rV   s              r   test_correct_directory_verbosez(TestCheck.test_correct_directory_verbose   sy   	 ((* 	8g{"78:E#L$>'RE#L$>'RE 8*e 8z",j!9 LILLI=0I!JKL $% $& ,&/2C ,vNN7+, ,*! 4D40 4dF34 44   !2B78 8		8 	8, , , ,4 48 8 8 8		8 	8s   1E'E
3E=D7	D+D7	&/EE(*EEE'+D40D7	7E <EEEEEE$	 E''E0c                     	 t        j                         5 }t        t        d   |      5  | j	                  |       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   rw   )r    rx   r   rr   rn   )r   r{   s     r   test_correct_directoryz TestCheck.test_correct_directory   s_    O((* 	4g l!;wO 4**734	4 	44 4	4 	4s!   AAAA	AA#c                     	 t        t        d         5 }d}|d| }| j                  t              5  | j	                  ||       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr   Iunindent does not match any outer indentation level (<tokenize>, line 3)
: Indentation Error: rl   r   rr   rH   rI   rn   r   r$   rl   s      r   test_when_wrong_indentedz"TestCheck.test_when_wrong_indented   s}    P\*:;< 	?	*CM!6se<C"":. ?**9#*>?		? 	?? ?		? 	?"   A$AA$A!	A$$A-c                     	 t        t        d         5 }d}|d| }| j                  t              5  | j	                  ||       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr
   z(('EOF in multi-line statement', (7, 0))
: Token Error: r   r   r   s      r   test_when_tokenize_tokenerrorz'TestCheck.test_when_tokenize_tokenerror   sz    S\*ABC 	?y=CM6C"":. ?**9#*>?	? 	?? ?	? 	?r   c                     	 t        t        d         5 }|d}|dz  }|dz  }dt        _        | j	                  ||       d d d        y # 1 sw Y   y xY w)Nr   z': *** Line 3: trouble in tab city! ***
z#offending line: '\tprint("world")'
z3inconsistent use of tabs and spaces in indentation
rC   rk   )r   rr   r:   rd   rn   r   r$   rk   s      r    test_when_nannynag_error_verbosez*TestCheck.test_when_nannynag_error_verbose   sl    	 \*<=> 	;)M!IJC<<CIIC H&&yc&:	; 	; 	;s   .AAc                     	 t        t        d         5 }| d}| j                  ||       d d d        y # 1 sw Y   y xY w)Nr   z 3 '\tprint("world")'
r   rq   r   s      r   test_when_nannynag_errorz"TestCheck.test_when_nannynag_error   sJ    Q\*<=> 	;)K9:C&&yc&:	; 	; 	;s   6?c                     	 d}|dt         j                   dt        j                  t         j                         d|d}| j	                  t
              5  | j                  ||       d d d        y # 1 sw Y   y xY w)Nz
no_file.pyz: I/O Error: [Errno z] z: rF   r   )errnoENOENTosstrerrorrH   rI   rn   )r   pathrl   s      r   test_when_no_filezTestCheck.test_when_no_file   st    D-ell^2U\\*+2dXR9z* 	6&&t&5	6 	6 	6s   A33A<c           	         	 t        j                         5 }t        t        d   |      }t        t        d   |      }|5 }|5 }d}|d| }| j	                  t
              5  | j                  ||       d d d        d d d        d d d        d d d        y # 1 sw Y   "xY w# 1 sw Y   &xY w# 1 sw Y   *xY w# 1 sw Y   y xY w)Nr   rw   r   r   r   r   )r    rx   r   rr   rH   rI   rn   )r   r{   
error_file	code_filee_filec_filerl   s          r   test_errored_directoryz TestCheck.test_errored_directory   s    M((* 	Ag(-.'J (\*gI  Avy AF6
"7u=&&z2 A..wC.@A	A A	A 	AA A	A A A A	A 	AsS   +B<B0B$#B	7B$?B0B<B!B$$B-)B00B9	5B<<CN)r,   r,   )r-   r.   r/   rg   rn   rt   r   r   r   r   r   r   r   r   r0   r   r   rb   rb      s=    #12
804??;;6Ar   rb   c                   D    e Zd Z	  ej                  d      d        Zd Zy)TestProcessTokensztabnanny.NannyNagc                 .   	 t        t        d         5 }t        |      5 }t        j                  t        j                  |j                               d d d        | j                  |j                         d d d        y # 1 sw Y   -xY w# 1 sw Y   y xY wrp   )
r   rr   openr:   process_tokenstokenizegenerate_tokensreadlineassertFalsecalled)r   MockNannyNagr$   r%   s       r   test_with_correct_codez(TestProcessTokens.test_with_correct_code	  s    K\,78 	2Ii NA''(@(@(LMN\001	2 	2N N	2 	2s"   B3A?#B?B	BBc           
         	 dD ]  }| j                  |      5  t        t        |         5 }t        |      5 }t	        j
                  |j                        }| j                  t        j                        5  t        j                  |       d d d        d d d        d d d        d d d         y # 1 sw Y   $xY w# 1 sw Y   (xY w# 1 sw Y   ,xY w# 1 sw Y   xY w)N)r   r   )key)r8   r   rr   r   r   r   r   rH   r:   r[   r   )r   r   r$   r%   tokenss        r   test_with_errored_codes_samplesz1TestProcessTokens.test_with_errored_codes_samples  s    L B 	<C#& <$\#%67 <9i <A!)!9!9!**!E!..x/@/@A <$33F;<<<< <	<
< << << << <sQ   CC?B<	7B0B<	CC0B95B<	<CCCCC	N)r-   r.   r/   r   patchr   r   r0   r   r   r   r     s(    .TZZ#$2 %2<r   r   c                   D    e Zd Z	 ddddddZd Zd Zd Zd Zd	 Zd
 Z	y)TestCommandLiner,   F)rm   rM   partialexpect_failurec                h   	 |rt        j                  ddg| \  }}}nt        j                  ddg| \  }}}t        j                  |      }t        j                  |      }|rd||f||ffD ]X  \  }	}
|
j                         }|	j                         D ]0  }| j                  ||      5  | j                  ||       d d d        2 Z y | j                  |j                         |j                                | j                  |j                         |j                                y # 1 sw Y   xY w)Nz-mr:   )stdoutput)	r   assert_python_failureassert_python_okr   fsdecode
splitlinesr8   rz   assertListEqual)r   rm   rM   r   r   rL   _rk   rl   r   r   _output_stds                r   validate_cmdzTestCommandLine.validate_cmd'  s"   P'==dJVQUVKAsC'88zQDQKAsC kk#kk#!'}= 5V ++-NN, 5D$w? 5dG45 555   !163D3D3FG  !163D3D3FG	5 5s   +D((D1c                     	 t        t        d         5 }|d}|dz  }| j                  ||d       d d d        y # 1 sw Y   y xY w)Nr   r   zFunindent does not match any outer indentation level (<string>, line 3)TrM   r   r   rr   r   )r   r$   rM   s      r   test_with_errored_filez&TestCommandLine.test_with_errored_file;  s^    F\*:;< 	M	"_5F - .FitL		M 	M 	Ms	   <Ac                 v    	 t        t        d         5 }| j                  |       d d d        y # 1 sw Y   y xY wrp   r   rs   s     r   test_with_error_free_filez)TestCommandLine.test_with_error_free_fileC  s7    O\,78 	)Ii(	) 	) 	)ru   c                 N    	 t        d      }d| d}| j                  |d       y )Nztabnanny.pyzUsage: z [-v] file_or_directory ...Tr   )r   r   )r   r   rM   s      r   test_command_usagez"TestCommandLine.test_command_usageH  s1    3&4& ;<=r   c                     	 t        t        d         5 }| d}| j                  d||       d d d        y # 1 sw Y   y xY w)Nr   rF   z-q)rm   r   )r   r$   rm   s      r   test_quiet_flagzTestCommandLine.test_quiet_flagN  sK    8\*<=> 	>)!{"%FdIf=	> 	> 	>s	   7A c                     	 t        t        d         5 }t        j                  d      j	                         }| j                  d||d       d d d        y # 1 sw Y   y xY w)Nr   "offending line: '\tprint("world")'z-vTrm   r   r   rr   textwrapdedentstripr   r   r   rm   s      r   test_verbose_modez!TestCommandLine.test_verbose_modeT  sb    J\*<=> 	G$__7eg  dDF		G 	G 	G   9AAc                     	 t        t        d         5 }t        j                  d      j	                         }| j                  d||d       d d d        y # 1 sw Y   y xY w)Nr   r   z-vvTr   r   r   s      r   test_double_verbose_modez(TestCommandLine.test_double_verbose_mode\  sb    P\*<=> 	H$__7eg  eT&$G		H 	H 	Hr   N)
r-   r.   r/   r   r   r   r   r   r   r   r0   r   r   r   r   $  s6    5)+BV[ H(M)
>>GHr   r   )unittestr   r   r   r   r:   r   r    r   test.supportr   r   r   r   test.support.os_helperr	   rr   r   r2   r?   rP   rb   r   r   r0   r   r   <module>r      s   
 $  	    $ $ )
		%	%	%	!	'K*Z &M( M"C8 C(98 96qA qAh< <<>Hh >Hr   