ó |G_Tc@€s¢dZddlmZddlmZddlmZmZddlZddlZddl m Z dd l m Z dd l mZd ejfd „ƒYZd ejfd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdejfd „ƒYZd!efd"„ƒYZd#„ZdS($sFTest suite for 2to3's parser and grammar files. This is the place to add tests for changes to 2to3's grammar, such as those merging the grammars for Python 2 and 3. In addition to specific tests for parts of the grammar we've changed, we also make sure we can parse the test_grammar.py files from both Python 2 and Python 3. iÿÿÿÿ(twith_statementi(tsupport(tdriverttest_dirN(ttokenizei(t ParseError(tpython_symbolst TestDrivercB€seZd„ZRS(cC€sad}tj|ƒ}|j|jdjdjtjƒ|j|jdjdjtjƒdS(Nsprint 1 print 2 ii(Rt parse_stringt assertEqualtchildrenttypetsymst print_stmt(tselftstt((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyt test_formfeeds$(t__name__t __module__R(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyRst GrammarTestcB€seZd„Zd„ZRS(cC€stj|ƒdS(N(RR(Rtcode((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pytvalidate#scC€s5y|j|ƒWntk r$n Xtdƒ‚dS(Ns Syntax shouldn't have been valid(RRtAssertionError(RR((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pytinvalid_syntax&s  (RRRR(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR"s tTestMatrixMultiplicationcB€seZd„ZRS(cC€s|jdƒ|jdƒdS(Nsa @ bsa @= b(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyt#test_matrix_multiplication_operator0s (RRR(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR/st TestYieldFromcB€seZd„ZRS(cC€s+|jdƒ|jdƒ|jdƒdS(Ns yield from xs(yield from x) + ys yield from(RR(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR6s  (RRR(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR5stTestRaiseChangescB€sYeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( cC€s|jdƒdS(Ntraise(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_1=scC€s|jdƒdS(Ns raise E, V(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_2@scC€s|jdƒdS(Ns raise E, V, T(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_3CscC€s|jdƒdS(Nsraise E, V, T, Z(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_invalid_1FscC€s|jdƒdS(Nsraise E1 from E2(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyt test_3x_styleIscC€s|jdƒdS(Nsraise E, V from E1(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_1LscC€s|jdƒdS(Nsraise E from E1, E2(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_2OscC€s|jdƒdS(Nsraise from E1, E2(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_3RscC€s|jdƒdS(Ns raise E from(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_4Us( RRRRR R!R"R#R$R%R&(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR<s        tTestFunctionAnnotationscB€sPeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(cC€s|jdƒdS(Nsdef f(x) -> list: pass(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_1[scC€s|jdƒdS(Nsdef f(x:int): pass(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_2^scC€s|jdƒdS(Nsdef f(*x:str): pass(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_3ascC€s|jdƒdS(Nsdef f(**x:float): pass(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_4dscC€s|jdƒdS(Nsdef f(x, y:1+2): pass(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_5gscC€s|jdƒdS(Nsdef f(a, (b:1, c:2, d)): pass(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_6jscC€s|jdƒdS(Ns/def f(a, (b:1, c:2, d), e:3=4, f=5, *g:6): pass(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_7mscC€sd}|j|ƒdS(Nsgdef f(a, (b:1, c:2, d), e:3=4, f=5, *g:6, h:7, i=8, j:9=10, **k:11) -> 12: pass(R(RR((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_8ps( RRR(R)R*R+R,R-R.R/(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR'Zs       t TestExceptcB€seZd„Zd„ZRS(cC€sd}|j|ƒdS(NsP try: x except E as N: y(R(RR((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_newwscC€sd}|j|ƒdS(NsN try: x except E, N: y(R(RR((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_olds(RRR1R2(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR0vs tTestSetLiteralcB€s,eZd„Zd„Zd„Zd„ZRS(cC€s|jdƒdS(Ns x = {'one'}(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR(ŠscC€s|jdƒdS(Nsx = {'one', 1,}(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR)scC€s|jdƒdS(Nsx = {'one', 'two', 'three'}(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR*scC€s|jdƒdS(Nsx = {2, 3, 4,}(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR+“s(RRR(R)R*R+(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR3‰s   tTestNumericLiteralscB€seZd„Zd„ZRS(cC€s|jdƒ|jdƒdS(Nt0o7777777777777t 0o7324528887(RR(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_octal_notation˜s cC€s|jdƒ|jdƒdS(Nt0b101010t 0b0101021(RR(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_binary_notationœs (RRR7R:(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR4—s t TestClassDefcB€seZd„ZRS(cC€sE|jdƒ|jdƒ|jdƒ|jdƒ|jdƒdS(Nsclass B(t=7): passsclass B(t, *args): passsclass B(t, **kwargs): passs!class B(t, *args, **kwargs): passs&class B(t, y=9, *args, **kwargs): pass(R(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_syntax¢s     (RRR<(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR;¡stTestParserIdempotencycB€s eZdZd„Zd„ZRS(s,A cut-down version of pytree_idempotency.py.cC€sçtjjdƒrdSxÊtjƒD]¼}t|dƒ}tj|jƒd}WdQX|j |d|ƒt|dƒ"}|j ƒ}|j |ƒ}WdQXt j |ƒ}t|ƒ}t|||ƒr#|jd|ƒq#q#WdS(Ntwintrbiscan't detect encoding for %strsIdempotency failed: %s(tsystplatformt startswithRtall_project_filestopenRtdetect_encodingtreadlinetassertIsNotNonetreadtdecodeRRtunicodetdifftfail(Rtfilepathtfptencodingtsourcettreetnew((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_all_project_files®s    cC€s8tjdƒtjdƒtjdƒtjdƒdS(Ns a, *b, c = x s [*a, b] = x s(z, *y, w) = m sfor *z, m in d: pass (RR(R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_extended_unpacking¿s   (RRt__doc__RTRU(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR=ªs t TestLiteralscB€s,eZd„Zd„Zd„Zd„ZRS(cC€stjtj|ƒdƒdS(Ns (RRRtdedent(RR((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyRÇscC€sd}|j|ƒdS(Nsá md5test(b"ª" * 80, (b"Test Using Larger Than Block-Size Key " b"and Larger Than One Block-Size Data"), "6f630fad67cda0ee1fb1f562db3aa53e") (R(RR((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_multiline_bytes_literalsÊscC€sd}|j|ƒdS(Ns¬ b""" """ (R(RR((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyt'test_multiline_bytes_tripquote_literalsÓscC€sd}|j|ƒdS(NsÞ md5test("ª" * 80, ("Test Using Larger Than Block-Size Key " "and Larger Than One Block-Size Data"), "6f630fad67cda0ee1fb1f562db3aa53e") (R(RR((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_multiline_str_literalsÜs(RRRRYRZR[(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyRWÅs  cC€sstddƒ}z|j|j|ƒƒWd|jƒXz'|jddƒ}tjd|ƒSWdtjdƒXdS(Nt@twt"s\"sdiff -u "%s" @(REtwritetencodetclosetreplacetostsystemtremove(tfntresultRPtf((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyRLæs (RVt __future__RtRRRRcRAt lib2to3.pgen2Rt pgen2.parseRtlib2to3.pygramRR tTestCaseRRRRRR'R0R3R4R;R=RWRL(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyts*      !