Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/lib2to3/tests/test_parser.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��Qc@�svdZddlmZddlmZddlmZmZddlZddlZddl	m
Z
dd	lmZdd
l
mZdejfd��YZd
ejfd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdejfd��YZdefd��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_stringtassertEqualtchildrenttypetsymst
print_stmt(tselftstt((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyt
test_formfeeds$(t__name__t
__module__R(((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyRstGrammarTestcB�seZd�Zd�ZRS(cC�stj|�dS(N(RR(Rtcode((s//sys/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((s//sys/lib/python2.7/lib2to3/tests/test_parser.pytinvalid_syntax&s

(RRRR(((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyR"s	tTestRaiseChangescB�sYeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	cC�s|jd�dS(Ntraise(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_10scC�s|jd�dS(Ns
raise E, V(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_23scC�s|jd�dS(Ns
raise E, V, T(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_36scC�s|jd�dS(Nsraise E, V, T, Z(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_invalid_19scC�s|jd�dS(Nsraise E1 from E2(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyt
test_3x_style<scC�s|jd�dS(Nsraise E, V from E1(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_1?scC�s|jd�dS(Nsraise E from E1, E2(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_2BscC�s|jd�dS(Nsraise from E1, E2(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_3EscC�s|jd�dS(Nsraise E from(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_4Hs(RRRRRRRR R!R"R#(((s//sys/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((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_1NscC�s|jd�dS(Nsdef f(x:int): pass(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_2QscC�s|jd�dS(Nsdef f(*x:str): pass(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_3TscC�s|jd�dS(Nsdef f(**x:float): pass(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_4WscC�s|jd�dS(Nsdef f(x, y:1+2): pass(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_5ZscC�s|jd�dS(Nsdef f(a, (b:1, c:2, d)): pass(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_6]scC�s|jd�dS(Ns/def f(a, (b:1, c:2, d), e:3=4, f=5, *g:6): pass(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_7`scC�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((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_8cs(
RRR%R&R'R(R)R*R+R,(((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyR$Ms							t
TestExceptcB�seZd�Zd�ZRS(cC�sd}|j|�dS(NsP
            try:
                x
            except E as N:
                y(R(RR((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_newjscC�sd}|j|�dS(NsN
            try:
                x
            except E, N:
                y(R(RR((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_oldrs(RRR.R/(((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyR-is	tTestSetLiteralcB�s,eZd�Zd�Zd�Zd�ZRS(cC�s|jd�dS(Nsx = {'one'}(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyR%}scC�s|jd�dS(Nsx = {'one', 1,}(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyR&�scC�s|jd�dS(Nsx = {'one', 'two', 'three'}(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyR'�scC�s|jd�dS(Nsx = {2, 3, 4,}(R(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyR(�s(RRR%R&R'R((((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyR0|s			tTestNumericLiteralscB�seZd�Zd�ZRS(cC�s|jd�|jd�dS(Nt0o7777777777777t0o7324528887(RR(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_octal_notation�s
cC�s|jd�|jd�dS(Nt0b101010t	0b0101021(RR(R((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_binary_notation�s
(RRR4R7(((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyR1�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((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_syntax�s




(RRR9(((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyR8�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	|dk	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_encodingtreadlinet
assertTruetNonetreadtdecodeRRtunicodetdifftfail(Rtfilepathtfptencodingtsourcettreetnew((s//sys/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((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_extended_unpacking�s


(RRt__doc__RRRS(((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyR:�s	tTestLiteralscB�s,eZd�Zd�Zd�Zd�ZRS(cC�stjtj|�d�dS(Ns

(RRRtdedent(RR((s//sys/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((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_multiline_bytes_literals�scC�sd}|j|�dS(Ns�
            b"""
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN">
            """
            (R(RR((s//sys/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((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyttest_multiline_str_literals�s(RRRRWRXRY(((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyRU�s					cC�sstdd�}z|j|j|��Wd|j�Xz'|jdd�}tjd|�SWdtjd�XdS(Nt@twt"s\"sdiff -u "%s" @(RBtwritetencodetclosetreplacetostsystemtremove(tfntresultRNtf((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyRJ�s(RTt
__future__RtRRRRaR>t
lib2to3.pgen2Rtpgen2.parseRtlib2to3.pygramRRtTestCaseRRRR$R-R0R1R8R:RURJ(((s//sys/lib/python2.7/lib2to3/tests/test_parser.pyt<module>s&	

	!

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].