%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/lib2to3/tests/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/lib2to3/tests/test_parser.pyo

ó
Pêáac@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((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyt
test_formfeed!s$(t__name__t
__module__R(((s5/usr/local/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
((s5/usr/local/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((s5/usr/local/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((s5/usr/local/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((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pytget_datajs(RRRJ(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyREistMyModulecseZdZˆƒZRS(tparsertestmodule(RRt__file__t
__loader__((RE(s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyRKlssGrammar.txti((Rttypest
ModuleTypeR9tmodulest
addCleanuptoperatortdelitemRtload_packaged_grammarRRF(R
tmodnameRKtg((REs5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_load_packaged_grammargs
N(RRRR,tunittesttskipIfR9R:tNoneRDRX(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR(s		$)tGrammarTestcBseZd„Zd„ZRS(cCstj|ƒdS(N(RR(R
tcode((s5/usr/local/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]((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pytinvalid_syntaxys

(RRR^R`(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR\us	tTestMatrixMultiplicationcBseZd„ZRS(cCs|jdƒ|jdƒdS(Nsa @ bsa @= b(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyt#test_matrix_multiplication_operatorƒs
(RRRb(((s5/usr/local/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
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyRb‰s

(RRRb(((s5/usr/local/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
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_1scCs|jdƒdS(Ns
raise E, V(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_2“scCs|jdƒdS(Ns
raise E, V, T(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_3–scCs|jdƒdS(Nsraise E, V, T, Z(R`(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_2x_style_invalid_1™scCs|jdƒdS(Nsraise E1 from E2(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyt
test_3x_styleœscCs|jdƒdS(Nsraise E, V from E1(R`(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_1ŸscCs|jdƒdS(Nsraise E from E1, E2(R`(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_2¢scCs|jdƒdS(Nsraise from E1, E2(R`(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_3¥scCs|jdƒdS(Nsraise E from(R`(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_3x_style_invalid_4¨s(RRRfRgRhRiRjRkRlRmRn(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyRds								tTestUnpackingGeneralizationscBsbeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d	„ZRS(
cCs|jdƒdS(Nsfunc(1, *(2, 3), 4)(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_mid_positional_star°scCs|jdƒdS(Ns,func(**{'eggs':'scrambled', 'spam':'fried'})(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_double_star_dict_literal³scCs|jdƒdS(Ns*func(spam='fried', **{'eggs':'scrambled'})(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyt,test_double_star_dict_literal_after_keywords¶scCs|jdƒdS(Ns[*{2}, 3, *[4]](R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_list_display¹scCs|jdƒdS(Ns{*{2}, 3, *[4]}(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_set_display¼scCs|jdƒdS(Ns{**{}}(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_dict_display_1¿scCs|jdƒdS(Ns{**{}, 3:4, **{5:6, 7:8}}(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_dict_display_2ÂscCs|jdƒdS(Nsf(a, *b, *c, d)(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_argument_unpacking_1ÅscCs|jdƒdS(Nsf(**a, **b)(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_argument_unpacking_2ÈscCs|jdƒdS(Nsf(2, *a, *b, **b, **c, **d)(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_argument_unpacking_3Ës(RRRpRqRrRsRtRuRvRwRxRy(((s5/usr/local/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
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_1ÑscCs|jdƒdS(Nsdef f(x:int): pass(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_2ÔscCs|jdƒdS(Nsdef f(*x:str): pass(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_3×scCs|jdƒdS(Nsdef f(**x:float): pass(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_4ÚscCs|jdƒdS(Nsdef f(x, y:1+2): pass(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_5ÝscCs|jdƒdS(Nsdef f(a, (b:1, c:2, d)): pass(R^(R
((s5/usr/local/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
((s5/usr/local/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((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_8æs(
RRR{R|R}R~RR€RR‚(((s5/usr/local/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((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_newíscCsd}|j|ƒdS(NsN
            try:
                x
            except E, N:
                y(R^(R
R((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_oldõs(RRR„R…(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyRƒìs	tTestSetLiteralcBs,eZd„Zd„Zd„Zd„ZRS(cCs|jdƒdS(Nsx = {'one'}(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR{scCs|jdƒdS(Nsx = {'one', 1,}(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR|scCs|jdƒdS(Nsx = {'one', 'two', 'three'}(R^(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR}scCs|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.pyR†ÿs			tTestNumericLiteralscBseZd„Zd„ZRS(cCs|jdƒ|jdƒdS(Nt0o7777777777777t0o7324528887(R^R`(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_octal_notations
cCs|jdƒ|jdƒdS(Nt0b101010t	0b0101021(R^R`(R
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_binary_notations
(RRRŠR(((s5/usr/local/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
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_new_syntaxs




(RRR(((s5/usr/local/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((s5/usr/local/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
((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_extended_unpacking5s


(RRt__doc__R£R¤(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR s	tTestLiteralscBs,eZd„Zd„Zd„Zd„ZRS(cCstjtj|ƒdƒdS(Ns

(RRRtdedent(R
R((s5/usr/local/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((s5/usr/local/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((s5/usr/local/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((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyttest_multiline_str_literalsRs(RRR^R¨R©Rª(((s5/usr/local/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((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyR›\s(&R¥tRRRRSRRGR"R7R9RRORYt
lib2to3.pgen2RRtpgen2.parseRtlib2to3.pygramRRtTestCaseRRR\RaRcRdRoRzRƒR†R‡RŽRR¦R›(((s5/usr/local/lib/python2.7/lib2to3/tests/test_parser.pyt<module>s<	M
 !
	!

Zerion Mini Shell 1.0