
    7bh6               	           d dl Z d dlZd dlmZ d dlmZ  e       Zd d d d d d	 d
 d dZ G d d      Z	 G d de j                        Z G d de j                        Zedk(  r e j                          yy)    N)StringIO)supportc                     t        |  S Nprintargssependfiles       9/opt/python-3.12.12/usr/lib/python3.12/test/test_print.py<lambda>r      s    UD\    c                     t        | d|iS )Nr   r   r	   s       r   r   r      s    Ut%<%<r   c                     t        | d|iS )Nr   r   r	   s       r   r   r          UT%:s%:r   c                     t        | ||dS )N)r   r   r   r	   s       r   r   r          Us%Er   c                     t        | d|iS )Nr   r   r	   s       r   r   r      r   r   c                     t        | ||dS )N)r   r   r   r	   s       r   r   r      r   r   c                     t        | ||dS )Nr   r   r   r	   s       r   r   r      s    Uds%Cr   c                     t        | |||dS )Nr   r   r   r   r	   s       r   r   r      s    Us$%Nr   ))FFF)FFT)FTF)FTT)TFF)TFT)TTF)TTTc                       e Zd Zd Zd Zy)ClassWith__str__c                     || _         y r   xselfr    s     r   __init__zClassWith__str__.__init__$   s	    r   c                     | j                   S r   r   r"   s    r   __str__zClassWith__str__.__str__'   s    vvr   N)__name__
__module____qualname__r#   r&    r   r   r   r   #   s    r   r   c                   .    e Zd Z	 eeefdZd Zd Zd Zy)	TestPrintc                     t         |t        u|t        u|t        uf   }t        j                         5 } |||||       d d d        | j	                  j                         |       y # 1 sw Y   *xY wr   )dispatch
NotDefinedr   captured_stdoutassertEqualgetvalue)r"   expectedr
   r   r   r   fnts           r   checkzTestPrint.check.   sn     s*,*,:-/ 0 $$&!tS#t$ ' 	x0 '&s   A((A1c                 p    t         t         f fd	} |dd        |dd        |dd        |dd	        |d
d        |dd	d        |ddd        |ddd        |dddd        |dddd        |ddd        |ddd        |dd        |ddd         |ddd         |ddd d         |d t        d      f        |d!t        d"      d#f        j                  t        t        dd$        j                  t        t        dd$        j                  t
        t        dd%       y )&Nc                     j                  | |||       t               }j                  d||||       j                  |j                         |        y )Nr    r   )r6   r   r1   r2   )r3   r
   r   r   or"   s        r   r    zTestPrint.test_print.<locals>.x@   sP     JJx3CJ8 
AJJr4ScJ: QZZ\84r   
r*   a
)azNone
r   z1 2
)      z1   2
)r>    r?   z1*2
*)r   z1 s)r>   sr9   )r   za
b
)r=   bz1.01)g      ?r>   r   z1*a*1.3+)r>   r=   g?+za

b
)r<   rC   z + + 
) r@   rE   za
 b
z*
zabc 1
abcr>      )r   )r/   r   assertRaises	TypeErrorr   AttributeErrorr!   s   ` r   
test_printzTestPrint.test_print?   s8   ",* 	5 	
$	%	(G	'6	)[!	'6s#	%r"	(JD)	&(+	*m#6	*l-	+(c2	)\"	)\t,	)\t,	)\t6	%"3')*	)&u-q12 	)UBA6)UBA6.%"=r   c                 H    G d d      } |       }t        d|dd       t        d|dd       t        d|d	
       | j                  |j                  d       | j                  |j                  d        G d d      }| j	                  t
        t         d |       d
       y )Nc                       e Zd Zd Zd Zd Zy),TestPrint.test_print_flush.<locals>.filelikec                      d| _         d| _        y )Nr9   r   )writtenflushedr%   s    r   r#   z5TestPrint.test_print_flush.<locals>.filelike.__init__j   s    ! r   c                 .    | xj                   |z  c_         y r   )rP   r"   strs     r   writez2TestPrint.test_print_flush.<locals>.filelike.writen   s    #r   c                 .    | xj                   dz  c_         y )Nr>   )rQ   r%   s    r   flushz2TestPrint.test_print_flush.<locals>.filelike.flushq   s    !r   N)r'   r(   r)   r#   rU   rW   r*   r   r   filelikerN   i   s    !$"r   rX   r>   r9   T)r   r   rW   r?   rG   F)r   rW   z123
c                       e Zd Zd Zd Zy)+TestPrint.test_print_flush.<locals>.noflushc                      y r   r*   rS   s     r   rU   z1TestPrint.test_print_flush.<locals>.noflush.write}   s    r   c                     t         r   )RuntimeErrorr%   s    r   rW   z1TestPrint.test_print_flush.<locals>.noflush.flush   s    ""r   N)r'   r(   r)   rU   rW   r*   r   r   noflushrZ   |   s    #r   r^   )r   r1   rP   rQ   rH   r]   )r"   rX   fr^   s       r   test_print_flushzTestPrint.test_print_flushg   s    		" 		" JaaRt,aaRt,aau%G,A&	# 	# 	,qwyMr   c                      G d d      }t        j                  t        dd       5  t               t        _        t         |              d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zd Zy)"TestPrint.test_gh130163.<locals>.Xc                 R    t               t        _        t        j                          y)Nfoo)r   sysstdoutr   
gc_collectr%   s    r   r&   z*TestPrint.test_gh130163.<locals>.X.__str__   s    %Z
""$r   N)r'   r(   r)   r&   r*   r   r   Xrc      s    r   ri   rg   )r   	swap_attrrf   r   rg   r   )r"   ri   s     r   test_gh130163zTestPrint.test_gh130163   s>    	 	 sHd3!CJ!#J 433s   $AAN)r'   r(   r)   r/   r6   rK   r`   rk   r*   r   r   r,   r,   +   s$    7 *:1"&>PN:	r   r,   c                   8    e Zd Z	 d Zd Zd Zd Zd Zd Zd Z	y)	TestPy2MigrationHintc                     d}| j                  t              5 }t        |       d d d        | j                  dt	        j
                               y # 1 sw Y   /xY w)Nzprint "Hello World"?Missing parentheses in call to 'print'. Did you mean print(...)rH   SyntaxErrorexecassertInrT   	exceptionr"   python2_print_strcontexts      r   test_normal_stringz'TestPy2MigrationHint.test_normal_string   N    1{+w"# , 	WG%%&	( ,+   AAc                     d}| j                  t              5 }t        |       d d d        | j                  dt	        j
                               y # 1 sw Y   /xY w)Nzprint "Hello World",ro   rp   ru   s      r   test_string_with_soft_spacez0TestPy2MigrationHint.test_string_with_soft_space   sN    2{+w"# , 	WG%%&	( ,+rz   c                     d}| j                  t              5 }t        |       d d d        | j                  dt	        j
                               y # 1 sw Y   /xY w)Nzprint  "Hello World", ro   rp   ru   s      r   %test_string_with_excessive_whitespacez:TestPy2MigrationHint.test_string_with_excessive_whitespace   sN    4{+w"# , 	WG%%&	( ,+rz   c                     d}| j                  t              5 }t        |       d d d        | j                  dt	        j
                               y # 1 sw Y   /xY w)Nz.if 1:
            print "Hello World"
        ro   rp   ru   s      r   #test_string_with_leading_whitespacez8TestPy2MigrationHint.test_string_with_leading_whitespace   sR     {+w"# , 	WG%%&	( ,+rz   c                     d}| j                  t              5 }t        |       d d d        | j                  dt	        j
                               y # 1 sw Y   /xY w)Nzprint p;ro   rp   ru   s      r   test_string_with_semicolonz/TestPy2MigrationHint.test_string_with_semicolon   sN    &{+w"# , 	WG%%&	( ,+rz   c                     d}| j                  t              5 }t        |       d d d        | j                  dt	        j
                               y # 1 sw Y   /xY w)Nzfor i in s: print iro   rp   ru   s      r    test_string_in_loop_on_same_linez5TestPy2MigrationHint.test_string_in_loop_on_same_line   ry   rz   c                 p   | j                  t              5 }t        t        j                  z	  df d d d        | j                  dt        j                               | j                  t              5 }t        dz	   d d d        | j                  dt        |j                               | j                  t              5 }t        t        j                  z	   d d d        | j                  dt        |j                               | j                  t              5 }t        t        j                  z   d d d        | j                  dt        |j                                G d d      }| j                  t         |       z	  d       y # 1 sw Y   XxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   }xY w)Nmessagez6Did you mean "print(<message>, file=<output_stream>)"?*   zDid you mean zDid you meanc                       e Zd Zd Zy)\TestPy2MigrationHint.test_stream_redirection_hint_for_py2_migration.<locals>.OverrideRRShiftc                      y)Nr   r*   )r"   lhss     r   __rrshift__zhTestPy2MigrationHint.test_stream_redirection_hint_for_py2_migration.<locals>.OverrideRRShift.__rrshift__   s    r   N)r'   r(   r)   r   r*   r   r   OverrideRRShiftr      s    r   r   )rH   rI   r   rf   stderrrs   rT   rt   maxassertNotInr1   )r"   rw   r   s      r   .test_stream_redirection_hint_for_py2_migrationzCTestPy2MigrationHint.test_stream_redirection_hint_for_py2_migration   sJ   y)WSZZ* * *+.w/@/@+A	C
 y)WRK * *+.w/@/@+A	C y)W3:: *#g.?.?*@A y)WSZZ *W->->)?@	 	 	/"33R87 *) *) *)
 *)s/   F2
F>F F,FF F),F5N)
r'   r(   r)   rx   r|   r~   r   r   r   r   r*   r   r   rm   rm      s*    ((((((9r   rm   __main__)unittestrf   ior   testr   objectr/   r.   r   TestCaser,   rm   r'   mainr*   r   r   <module>r      s     
  X
 	2<:E:ECN!* b!! bJW98,, W9v zHMMO r   