Current File : //opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyo
�
��#ec@s%dZddlmZddlmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlmZdd	lmZdd
lmZdejfd��YZd
ejfd��YZdejfd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZ defd ��YZ!d!efd"��YZ"d#ejfd$��YZ#d%efd&��YZ$d'�Z%dS((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(tsupport(tdriverttest_diri����N(R(ttokenizei(t
ParseError(tpython_symbolst
TestDrivercBseZd�ZRS(cCsad}tj|�}|j|jdjdjtj�|j|jdjdjtj�dS(Nsprint 1
print 2
ii(Rtparse_stringtassertEqualtchildrenttypetsymst
print_stmt(tselftstt((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyt
test_formfeed!s$(t__name__t
__module__R(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyRstTestPgen2CachingcBsGeZd�Zd�Zejejdkd�d��Z	d�Z
RS(cCs tjtjdtdt�dS(Ntsavetforce(tpgen2_drivertload_grammarRtgrammar_pathtFalsetTrue(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_load_grammar_from_txt_file)scCs�tj�}z�tjj|tjjtj��}tj	tj|�t
j|�}t
j|dt
dt
�|jtjj|��tj|�t
j|dtdt�Wdtj|�XdS(NRR(ttempfiletmkdtemptostpathtjointbasenameRRtshutiltcopyRt_generate_pickle_nameRRt
assertTruetexiststunlinkRtrmtree(R
ttmpdirtgrammar_copytpickle_name((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_load_grammar_from_pickle,s	
ssys.executable requiredc
Cs�tj�}tjj|d�}z�tj|�tjjtj�}tjj||�}tjj||�}t	j
tj|�t	j
tj|�tj|�}tj|�}|j
||�tj|dtdt�|jtjj|��ttj�}d|d<tjtjdd|fgd|�|jtjj|��t|d	��A}	t|d	��)}
|j|	j�|
j�d
d�WdQXWdQXWdt	j|�XdS(NtsubdirRRtrandomtPYTHONHASHSEEDs-cs{
from lib2to3.pgen2 import driver as pgen2_driver
pgen2_driver.load_grammar(%r, save=True, force=True)
                    tenvtrbtmsgsGGrammar caches generated using different hash seeds were not identical.(RRRRR tmkdirR!RRR"R#RR$tassertNotEqualRRR%R&tdicttenviront
subprocesst
check_calltsyst
executabletopenRtreadR((R
R)t	tmpsubdirtgrammar_baseR*tgrammar_sub_copyR+tpickle_sub_nametsub_envt
pickle_f_1t
pickle_f_2((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyt!test_load_grammar_from_subprocess>s8
	
	cs�td}ddd��Y�dtjf�fd��Y}||�tj|<|jtjtj|�tj	|d�}|j
|jd�dS(	Ns
.load_testtMyLoadercBseZd�ZRS(cSstjidd6�S(Nitelephant(tpickletdumps(R
twhere((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pytget_datajs(RRRJ(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyREistMyModulecseZdZ��ZRS(tparsertestmodule(RRt__file__t
__loader__((RE(s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyRKlssGrammar.txti((Rttypest
ModuleTypeR9tmodulest
addCleanuptoperatortdelitemRtload_packaged_grammarRRF(R
tmodnameRKtg((REs9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_load_packaged_grammargs
N(RRRR,tunittesttskipIfR9R:tNoneRDRX(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR(s		$)tGrammarTestcBseZd�Zd�ZRS(cCstj|�dS(N(RR(R
tcode((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pytvalidatevscCs5y|j|�Wntk
r$n
Xtd��dS(Ns Syntax shouldn't have been valid(R^RtAssertionError(R
R]((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pytinvalid_syntaxys

(RRR^R`(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR\us	tTestMatrixMultiplicationcBseZd�ZRS(cCs|jd�|jd�dS(Nsa @ bsa @= b(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyt#test_matrix_multiplication_operator�s
(RRRb(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyRa�st
TestYieldFromcBseZd�ZRS(cCs+|jd�|jd�|jd�dS(Nsyield from xs(yield from x) + ys
yield from(R^R`(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyRb�s

(RRRb(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyRc�stTestRaiseChangescBsYeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	cCs|jd�dS(Ntraise(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_1�scCs|jd�dS(Ns
raise E, V(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_2�scCs|jd�dS(Ns
raise E, V, T(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_3�scCs|jd�dS(Nsraise E, V, T, Z(R`(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_invalid_1�scCs|jd�dS(Nsraise E1 from E2(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyt
test_3x_style�scCs|jd�dS(Nsraise E, V from E1(R`(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_1�scCs|jd�dS(Nsraise E from E1, E2(R`(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_2�scCs|jd�dS(Nsraise from E1, E2(R`(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_3�scCs|jd�dS(Nsraise E from(R`(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_4�s(RRRfRgRhRiRjRkRlRmRn(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyRd�s								tTestUnpackingGeneralizationscBsbeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
cCs|jd�dS(Nsfunc(1, *(2, 3), 4)(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_mid_positional_star�scCs|jd�dS(Ns,func(**{'eggs':'scrambled', 'spam':'fried'})(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_double_star_dict_literal�scCs|jd�dS(Ns*func(spam='fried', **{'eggs':'scrambled'})(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyt,test_double_star_dict_literal_after_keywords�scCs|jd�dS(Ns[*{2}, 3, *[4]](R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_list_display�scCs|jd�dS(Ns{*{2}, 3, *[4]}(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_set_display�scCs|jd�dS(Ns{**{}}(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_dict_display_1�scCs|jd�dS(Ns{**{}, 3:4, **{5:6, 7:8}}(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_dict_display_2�scCs|jd�dS(Nsf(a, *b, *c, d)(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_argument_unpacking_1�scCs|jd�dS(Nsf(**a, **b)(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_argument_unpacking_2�scCs|jd�dS(Nsf(2, *a, *b, **b, **c, **d)(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_argument_unpacking_3�s(RRRpRqRrRsRtRuRvRwRxRy(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyRo�s									tTestFunctionAnnotationscBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cCs|jd�dS(Nsdef f(x) -> list: pass(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_1�scCs|jd�dS(Nsdef f(x:int): pass(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_2�scCs|jd�dS(Nsdef f(*x:str): pass(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_3�scCs|jd�dS(Nsdef f(**x:float): pass(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_4�scCs|jd�dS(Nsdef f(x, y:1+2): pass(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_5�scCs|jd�dS(Nsdef f(a, (b:1, c:2, d)): pass(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_6�scCs|jd�dS(Ns/def f(a, (b:1, c:2, d), e:3=4, f=5, *g:6): pass(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_7�scCsd}|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^(R
R((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_8�s(
RRR{R|R}R~RR�R�R�(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyRz�s							t
TestExceptcBseZd�Zd�ZRS(cCsd}|j|�dS(NsP
            try:
                x
            except E as N:
                y(R^(R
R((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_new�scCsd}|j|�dS(NsN
            try:
                x
            except E, N:
                y(R^(R
R((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_old�s(RRR�R�(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR��s	tTestSetLiteralcBs,eZd�Zd�Zd�Zd�ZRS(cCs|jd�dS(Nsx = {'one'}(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR{scCs|jd�dS(Nsx = {'one', 1,}(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR|scCs|jd�dS(Nsx = {'one', 'two', 'three'}(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR}scCs|jd�dS(Nsx = {2, 3, 4,}(R^(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR~	s(RRR{R|R}R~(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR��s			tTestNumericLiteralscBseZd�Zd�ZRS(cCs|jd�|jd�dS(Nt0o7777777777777t0o7324528887(R^R`(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_octal_notations
cCs|jd�|jd�dS(Nt0b101010t	0b0101021(R^R`(R
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_binary_notations
(RRR�R�(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR�
s	tTestClassDefcBseZd�ZRS(cCsE|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
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_syntaxs




(RRR�(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR�stTestParserIdempotencycBs eZdZd�Zd�ZRS(s,A cut-down version of pytree_idempotency.py.cCs�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(NtwinR1iscan't detect encoding for %strsIdempotency failed: %s(R9tplatformt
startswithRtall_project_filesR;Rtdetect_encodingtreadlinetassertIsNotNoneR<tdecodeRRtunicodetdifftfail(R
tfilepathtfptencodingtsourcettreetnew((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_all_project_files$s	cCs8tjd�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
((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_extended_unpacking5s


(RRt__doc__R�R�(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR� s	tTestLiteralscBs,eZd�Zd�Zd�Zd�ZRS(cCstjtj|�d�dS(Ns

(RRRtdedent(R
R((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR^=scCsd}|j|�dS(Ns�
            md5test(b"�" * 80,
                    (b"Test Using Larger Than Block-Size Key "
                     b"and Larger Than One Block-Size Data"),
                    "6f630fad67cda0ee1fb1f562db3aa53e")
            (R^(R
R((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_multiline_bytes_literals@scCsd}|j|�dS(Ns�
            b"""
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN">
            """
            (R^(R
R((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyt'test_multiline_bytes_tripquote_literalsIscCsd}|j|�dS(Ns�
            md5test("�" * 80,
                    ("Test Using Larger Than Block-Size Key "
                     "and Larger Than One Block-Size Data"),
                    "6f630fad67cda0ee1fb1f562db3aa53e")
            (R^(R
R((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyttest_multiline_str_literalsRs(RRR^R�R�R�(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR�;s					cCsstdd�}z|j|j|��Wd|j�Xz'|jdd�}tjd|�SWdtjd�XdS(Nt@twt"s\"sdiff -u "%s" @(R;twritetencodetclosetreplaceRtsystemtremove(tfntresultR�tf((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyR�\s(&R�tRRRRSRRGR"R7R9RRORYt
lib2to3.pgen2RRtpgen2.parseRtlib2to3.pygramRRtTestCaseRRR\RaRcRdRoRzR�R�R�R�R�R�R�(((s9/opt/RZpython2/lib/python2.7/lib2to3/tests/test_parser.pyt<module>s<	M
 !
	!