^c@sddlZddlmZddlZddlZddlZddlZddlZddlZdZ dZ dZ dZ dZ dZd Zd Zd ejfd YZd efdYZdefdYZdZedkrendS(iN(t test_supportcCs(t|d}|j}WdQX|S(snRead and return the contents of a Python source file (as a string), taking into account the file encoding.trN(topentread(tfilenametpyfiletsource((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyt read_pyfile ssQdef f(): for x in range(10): break else: y = 2 z = 3 sIdef g(): while True: break else: y = 2 z = 3 sQfrom . import fred from .. import barney from .australia import shrimp as prawns s@f1(arg) @f2 class Foo: pass s=if cond1: suite1 elif cond2: suite2 else: suite3 s,if cond1: suite1 elif cond2: suite2 sctry: suite1 except ex1: suite2 except ex2: suite3 else: suite4 finally: suite5 t ASTTestCasecBseZdZddZRS(cCsDtj|}tj|}|jtj|tj|dS(N(tasttdumpt assertEqual(tselftast1tast2tdump1tdump2((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pytassertASTEqualMstinternalcCslt||dtj}tj}tj|||j}t||dtj}|j||dS(Ntexec( tcompileR t PyCF_ONLY_ASTt cStringIOtStringIOtunparsetUnparsertgetvalueR(R tcode1RR tunparse_buffertcode2R((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pytcheck_roundtripRs   (t__name__t __module__RR(((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyRLs tUnparseTestCasecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZRS(cCs|jddS(Ns del x, y, z(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_del_statement]scCs|jd|jddS(Ns45 << 2s13 >> 7(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyt test_shifts`s cCs|jtdS(N(Rtfor_else(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyt test_for_elsedscCs|jtdS(N(Rt while_else(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_while_elsegscCsE|jd|jd|jd|jd|jddS(Ns(-1)**7s(-1.)**8s(-1j)**6snot True or FalsesTrue or not False(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_unary_parensjs     cCs|jddS(Ns 3 .__abs__()(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_integer_parensqscCs8|jd|jd|jd|jddS(Nt1e1000s-1e1000t1e1000js-1e1000j(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_huge_floatts   cCs7|jttj d|jdtjddS(Nis-(%s)(Rtstrtsystmaxint(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyt test_min_intzscCsR|jd|jd|jd|jd|jd|jddS(Nt7js-7js-(7j)t0js-0js-(0j)(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_imaginary_literals~s      cCsl|jd|jd|jd|jd|jd|jd|jd|jddS( Ns-0s-(0)s-0b0s-(0b0)s-0o0s-(0o0)s-0x0s-(0x0)(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_negative_zeros       cCs|jddS(Ns(lambda: int)()(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_lambda_parenthesesscCs|jd|jddS(Ns 1 < 4 <= 5sa is b is c is not d(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_chained_comparisonss cCs_|jd|jd|jd|jd|jd|jd|jddS(Ns def f(): passsdef f(a): passsdef f(b = 2): passsdef f(a, b): passsdef f(a, b = 2): passsdef f(a = 5, b = 2): passsdef f(*args, **kwargs): pass(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_function_argumentss      cCs|jtdS(N(Rtrelative_import(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_relative_importscCs|jddS(Nsb'123'(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyt test_bytesscCs|jddS(Ns{'a', 'b', 'c'}(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_set_literalscCs|jddS(Ns{x for x in range(5)}(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_set_comprehensionscCs|jddS(Ns{x: x*x for x in range(10)}(R(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_dict_comprehensionscCs|jtdS(N(Rtclass_decorator(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_class_decoratorsscCs|jt|jtdS(N(Rtelif1telif2(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyt test_elifss cCs|jtdS(N(Rttry_except_finally(R ((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyttest_try_except_finallys(RR R"R#R%R'R(R)R,R0R3R4R5R6R7R9R:R;R<R=R?RBRD(((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyR!Zs*                  tDirectoryTestCasecBs2eZdZdejjddfZdZRS(s:Test roundtrip behaviour on all files in Lib and Lib/test.tLibttestcCstjjtjjttjtj}g}x~|jD]s}tjj||}xUtj|D]D}|jdre|j d re|j tjj||qeqeWq:Wx<|D]4}t j rd|GHnt |}|j|qWdS(Ns.pytbads Testing %s(tostpathtjointdirnamet__file__tpardirttest_directoriestlistdirtendswitht startswithtappendRtverboseRR(R tdist_dirtnamestdttest_dirtnRR((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyt test_filess*'    (RR t__doc__RIRJRKRORZ(((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyREscCstjttdS(N(Rt run_unittestR!RE(((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyt test_mainst__main__(tunittestRGRRR.RIttokenizeR RRR$R&R8R>R@RARCtTestCaseRR!RER]R(((s0/usr/lib64/python2.7/Demo/parser/test_unparse.pyts*           _