a ze{ @sddlZddlZddlmZddlmZeZddddddddd dd dd dd dd ZGdddZ Gdddej Z Gdddej Z e dkredS)N)StringIO)supportcCst|SNprintargssependfiler C/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_print.pyrcCst|d|iS)Nr rrr r r rrcCst|d|iS)Nr rrr r r rrcCst|||dS)N)r r rrr r r rrcCst|d|iS)Nr rrr r r rrcCst|||dS)N)r r rrr r r rrcCst|||dS)Nr r rrr r r rrcCst||||dS)Nr r r rrr r r rr))FFF)FFT)FTF)FTT)TFF)TFT)TTF)TTTc@seZdZddZddZdS)ClassWith__str__cCs ||_dSrxselfrr r r __init__$szClassWith__str__.__init__cCs|jSrrrr r r __str__'szClassWith__str__.__str__N)__name__ __module__ __qualname__rrr r r r r#src@s0eZdZdZeeefddZddZddZdS) TestPrintz-Test correct operation of the print function.cCsdt|tu|tu|tuf}t}|||||Wdn1sF0Y|||dSr)dispatch NotDefinedrZcaptured_stdout assertEqualgetvalue)rexpectedrr r r fntr r r check.s ,zTestPrint.checkcs<ttffdd }|dd|dd|dd|d d |d d |d d dd|dddd|dddd|ddddd|ddddd|dddd|dddd|d d|d ddd|d ddd|d dddd|d!tdf|d"td#d$fjttdd%djttdd%djttddd&dS)'Ncs@j||||dt}jd||||d||dS)Nrr)r%rr r!)r"rr r orr r r@szTestPrint.test_print..x r a )azNone rz1 2 )z1 2 )r+ r,z1*2 *)r z1 s)r+sr&)r za b )r*bz1.01)g?r+rz1*a*1.3+)r+r*g?+za b )r)r0z+ + )r-r2za b z* zabc 1 abcr+)r )rr assertRaises TypeErrorrAttributeErrorrr rr test_print?s,      zTestPrint.test_printcCsGddd}|}td|dddtd|dddtd|d d ||jd ||jdGd d d }|jttd|dd dS)Nc@s$eZdZddZddZddZdS)z,TestPrint.test_print_flush..filelikecSsd|_d|_dS)Nr&r)writtenflushedrr r r rjsz5TestPrint.test_print_flush..filelike.__init__cSs|j|7_dSr)r9rstrr r r writensz2TestPrint.test_print_flush..filelike.writecSs|jd7_dS)Nr+)r:rr r r flushqsz2TestPrint.test_print_flush..filelike.flushN)rrrrr=r>r r r r filelikeisr?r+r&T)r r r>r,r4F)r r>z123 c@seZdZddZddZdS)z+TestPrint.test_print_flush..noflushcSsdSrr r;r r r r=}sz1TestPrint.test_print_flush..noflush.writecSstdSr) RuntimeErrorrr r r r>sz1TestPrint.test_print_flush..noflush.flushN)rrrr=r>r r r r noflush|srA)rr r9r:r5r@)rr?frAr r r test_print_flushgs zTestPrint.test_print_flushN)rrr__doc__rr%r8rCr r r r r+s  (rc@sHeZdZdZddZddZddZdd Zd d Zd d Z ddZ dS)TestPy2MigrationHintzwTest that correct hint is produced analogous to Python3 syntax, if print statement is executed as in Python 2. cCsLd}|t}t|Wdn1s,0Y|dt|jdS)Nzprint "Hello World"print("Hello World")r5 SyntaxErrorexecassertInr< exceptionrZpython2_print_strcontextr r r test_normal_strings &z'TestPy2MigrationHint.test_normal_stringcCsLd}|t}t|Wdn1s,0Y|dt|jdS)Nzprint "Hello World",print("Hello World", end=" ")rGrLr r r test_string_with_soft_spaces &z0TestPy2MigrationHint.test_string_with_soft_spacecCsLd}|t}t|Wdn1s,0Y|dt|jdS)Nzprint "Hello World", rOrGrLr r r %test_string_with_excessive_whitespaces &z:TestPy2MigrationHint.test_string_with_excessive_whitespacecCsLd}|t}t|Wdn1s,0Y|dt|jdS)Nz.if 1: print "Hello World" rFrGrLr r r #test_string_with_leading_whitespaces &z8TestPy2MigrationHint.test_string_with_leading_whitespacecCsLd}|t}t|Wdn1s,0Y|dt|jdS)Nzprint p;zprint(p)rGrLr r r test_string_with_semicolons &z/TestPy2MigrationHint.test_string_with_semicoloncCsLd}|t}t|Wdn1s,0Y|dt|jdS)Nzfor i in s: print izprint(i)rGrLr r r test_string_in_loop_on_same_lines &z5TestPy2MigrationHint.test_string_in_loop_on_same_linecCs>|t}ttj?dfWdn1s.0Y|dt|j|t}td?Wdn1sr0Y|dt|j|t}ttj?Wdn1s0Y| dt|j|t}ttj>Wdn1s0Y| dt|jGddd}| t|?ddS)Nmessagez6Did you mean "print(, file=)"?*z Did you mean z Did you meanc@seZdZddZdS)z\TestPy2MigrationHint.test_stream_redirection_hint_for_py2_migration..OverrideRRShiftcSsdS)NrVr )rZlhsr r r __rrshift__szhTestPy2MigrationHint.test_stream_redirection_hint_for_py2_migration..OverrideRRShift.__rrshift__N)rrrrWr r r r OverrideRRShiftsrX) r5r6rsysstderrrJr<rKmaxZ assertNotInr )rrMrXr r r .test_stream_redirection_hint_for_py2_migrations$ , & ( (zCTestPy2MigrationHint.test_stream_redirection_hint_for_py2_migrationN) rrrrDrNrPrQrRrSrTr\r r r r rEs rE__main__)ZunittestrYiortestrobjectrrrZTestCaserrErmainr r r r s$   ZU