ó {G_Tc@sQdZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z ejƒ r«ejdƒ‚nejjejjejjejjeƒƒƒdƒZejjedƒZdejfd „ƒYZd ejfd „ƒYZd „Zed krMejƒndS(sºTests for scripts in the Tools directory. This file contains regression tests for some of the scripts found in the Tools directory of a Python checkout or tarball, such as reindent.py. iÿÿÿÿN(t test_support(tassert_python_okttemp_dirs'test irrelevant for an installed PythontToolstscriptst ReindentTestscBs/eZejjedƒZd„Zd„ZRS(s reindent.pycCst|jƒdS(N(Rtscript(tself((s+/usr/local/lib/python2.7/test/test_tools.pyt test_noargsscCs?t|jdƒ\}}}|j|dƒ|j|dƒdS(Ns-ht(RRt assertEqualt assertGreater(Rtrctoutterr((s+/usr/local/lib/python2.7/test/test_tools.pyt test_help"s( t__name__t __module__tostpathtjoint scriptsdirRRR(((s+/usr/local/lib/python2.7/test/test_tools.pyRs t PindentTestscBs€eZejjedƒZd„Zd„Zd„Z d„Z d„Z d„Z d„Z d„Zd „Zd „Zd „ZRS( s pindent.pyc CsJt|ƒ8}t|ƒ#}|j|jƒ|jƒƒWdQXWdQXdS(N(topenR t readlines(Rtfn1tfn2tf1tf2((s+/usr/local/lib/python2.7/test/test_tools.pytassertFileEqual+scGs]tjtj|jf|dtjdtjdtƒ}|j|ƒ\}}|j|ƒ|S(Ntstdintstdouttuniversal_newlines( t subprocesstPopentsyst executableRtPIPEtTruet communicatet assertIsNone(RtsourcetargstprocR R((s+/usr/local/lib/python2.7/test/test_tools.pytpindent/s  cCs!djd„|jƒDƒƒdS(Ns css|]}|jƒVqdS(N(tlstrip(t.0tline((s+/usr/local/lib/python2.7/test/test_tools.pys 9s(Rt splitlines(Rtdata((s+/usr/local/lib/python2.7/test/test_tools.pyt lstriplines8sc Csðd|_tƒØ}tjj|dƒ}t|jƒ}|jƒ}WdQXt|dƒ}|j |ƒWdQXt |jd|ƒ\}}}|j |dƒ|j |dƒ|d}|j tjj |ƒƒt|ƒ}|j |jƒ|ƒWdQXt|ƒ}|jƒ} WdQXt| ddƒ|j |j| dƒ|ƒ|j |j|dƒ| ƒt |jd|ƒ\}}}|j |dƒ|j |dƒt|ƒ}|j |jƒ| ƒWdQXt|ƒ}|j |jƒ|ƒWdQX|j|ƒ} t|dƒ}|j | ƒWdQXt |jd|ƒ\}}}|j |dƒ|j |dƒt|ƒ}|j |jƒ| ƒWdQXt|ƒ}|jƒ} WdQXt| ddƒ|j |j| dƒ| ƒWdQXdS( Ns_test.pytws-dR t~texecs-cs-r(tNonetmaxDiffRRRRRRtreadtwriteRR t assertTruetexiststcompileR,R2( Rt directoryt data_pathtftclosedR R Rtbackuptcleantbrokentindented((s+/usr/local/lib/python2.7/test/test_tools.pyt test_selftest;sL   cCsp|j|j|dƒ|ƒ|j|j|dƒ|ƒ|j|ƒ}|j|j|ddddƒ|ƒdS(Ns-cs-ds-rs-es-st4(R R,R2(RRBR@RC((s+/usr/local/lib/python2.7/test/test_tools.pyt pindent_testfscCs2tjdƒ}tjdƒ}|j||ƒdS(Ns: if a: pass if a: pass else: pass if a: pass elif: pass else: pass while a: break while a: break else: pass for i in a: break for i in a: break else: pass try: pass finally: pass try: pass except TypeError: pass except ValueError: pass else: pass try: pass except TypeError: pass except ValueError: pass finally: pass with a: pass class A: pass def f(): pass s` if a: pass # end if if a: pass else: pass # end if if a: pass elif: pass else: pass # end if while a: break # end while while a: break else: pass # end while for i in a: break # end for for i in a: break else: pass # end for try: pass finally: pass # end try try: pass except TypeError: pass except ValueError: pass else: pass # end try try: pass except TypeError: pass except ValueError: pass finally: pass # end try with a: pass # end with class A: pass # end class A def f(): pass # end def f (ttextwraptdedentRG(RRBR@((s+/usr/local/lib/python2.7/test/test_tools.pyttest_statementsls ? L cCs2tjdƒ}tjdƒ}|j||ƒdS(Ns÷ def foobar(a, b): if a == b: a = a+1 elif a < b: b = b-1 if b > a: a = a-1 else: print 'oops!' sJ def foobar(a, b): if a == b: a = a+1 elif a < b: b = b-1 if b > a: a = a-1 # end if else: print 'oops!' # end if # end def foobar (RHRIRG(RRBR@((s+/usr/local/lib/python2.7/test/test_tools.pyttest_multilevelýs   cCstjdƒ}tjdƒ}|j|j|dƒ|ƒ|j|j|dƒ|ƒ|j|ƒ}|j|j|ddddƒ|ƒtjd ƒ}tjd ƒ}|j|j|dƒ|ƒ|j|j|dƒ|ƒ|j|ƒ}|j|j|dƒ|ƒdS( Ns\ if a: if b: pass s if a: if b: pass # end if # end if s-cs-ds-rs-es-st9sD if a: if b: pass so if a: if b: pass # end if # end if (RHRIR R,R2(RRBR@RC((s+/usr/local/lib/python2.7/test/test_tools.pyttest_preserve_indentss   %  cCsZtjdƒ}tjdƒ}|j|j|dƒ|ƒ|j|j|dƒ|ƒdS(Nsƒ class\ \ A: def \ f: pass s¸ class\ \ A: def \ f: pass # end def f # end class A s-cs-d(RHRIR R,(RRBR@((s+/usr/local/lib/python2.7/test/test_tools.pyttest_escaped_newline9s   cCs2tjdƒ}tjdƒ}|j||ƒdS(Ns4 if a: pass sI if a: pass # end if (RHRIRG(RRBR@((s+/usr/local/lib/python2.7/test/test_tools.pyttest_empty_lineQs   cCs2tjdƒ}tjdƒ}|j||ƒdS(Ns# if a: pass s8 if a: pass # end if (RHRIRG(RRBR@((s+/usr/local/lib/python2.7/test/test_tools.pyt test_oneline_s   (RRRRRRRRR,R2RERGRJRKRMRNRORP(((s+/usr/local/lib/python2.7/test/test_tools.pyR(s   +  ‘  "  cCs<tjgtƒjƒD]}t|tƒr|^qŒdS(N(Rt run_unittesttglobalstvaluest isinstancettype(tobj((s+/usr/local/lib/python2.7/test/test_tools.pyt test_mainjst__main__(t__doc__RR#tunittesttshutilR!t sysconfigttempfileRHttestRttest.script_helperRRtis_python_buildtSkipTestRRtdirnamet__file__tbasepathRtTestCaseRRRWRtmain(((s+/usr/local/lib/python2.7/test/test_tools.pyts*         0  ÿC