%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_util.pyo

ó
Pêáac@s{dZddlmZddlZddlmZmZddlm	Z	ddl
mZmZm
Z
mZddlmZd	d
„Zdejfd„ƒYZd
ejfd„ƒYZdejfd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdejfd„ƒYZdejfd„ƒYZdejfd„ƒYZdejfd„ƒYZdS(s' Test suite for the code in fixer_util i(tsupportiÿÿÿÿN(tNodetLeaf(t
fixer_util(tAttrtNametCalltComma(ttokenicCs@tj|ƒ}x!t|ƒD]}|jd}qWd|_|S(Ni(Rtparse_stringtrangetchildrentNonetparent(tcodetstrip_levelsttreeti((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pytparses
	t
MacroTestCasecBseZd„ZRS(cCsGt|ttfƒr-ttjj|ƒ}n|jt|ƒ|ƒdS(N(	t
isinstancettupletlistRRtsymstsimple_stmttassertEqualtstr(tselftnodetstring((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyt	assertStrs(t__name__t
__module__R(((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyRst
Test_is_tuplecBs#eZd„Zd„Zd„ZRS(cCstjt|ddƒƒS(NRi(Rtis_tupleR(RR((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyR" scCsr|j|jdƒƒ|j|jdƒƒ|j|jdƒƒ|j|jdƒƒ|j|jdƒƒdS(Ns(a, b)s(a, (b, c))s((a, (b, c)),)s(a,)s()(t
assertTrueR"(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyt
test_valid#s
cCs0|j|jdƒƒ|j|jdƒƒdS(Ns(a)s('foo') % (b, c)(tassertFalseR"(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_invalid*s(RR R"R$R&(((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyR!s		tTest_is_listcBs#eZd„Zd„Zd„ZRS(cCstjt|ddƒƒS(NRi(Rtis_listR(RR((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyR(0scCsr|j|jdƒƒ|j|jdƒƒ|j|jdƒƒ|j|jdƒƒ|j|jdƒƒdS(Ns[]s[a]s[a, b]s[a, [b, c]]s[[a, [b, c]],](R#R((R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyR$3s
cCs|j|jdƒƒdS(Ns[]+[](R%R((R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyR&:s(RR R(R$R&(((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyR'/s		t	Test_AttrcBseZd„Zd„ZRS(cCsZtdddƒ}|jttdƒtdƒƒdƒ|jt|tdƒƒdƒdS(Nsfoo()Ritatbsa.bsfoo().b(RRRR(Rtcall((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest?s%cCs5ttdƒtdƒƒ}|jt|ƒtƒdS(NR*R+(RRRttypeR(Rtattr((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_returnsEs(RR R-R0(((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyR)>s	t	Test_NamecBseZd„ZRS(cCsL|jtdƒdƒ|jtdƒdƒ|jtdddƒdƒdS(NR*s
foo.foo().bartprefixR+tba(RR(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyR-Ks(RR R-(((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyR1Jst	Test_CallcBs eZddd„Zd„ZRS(cCsfg}t|tƒrPx+|D]#}|j|ƒ|jtƒƒqW|jƒntt|ƒ||ƒS(sHelp the next test(RRtappendRtpopRR(RtnametargsR2Rtarg((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyt_CallRs


c	Cs"dttjdƒttjdƒttjdƒgttjdƒttjdƒttjdƒttjdƒgttjdƒttjdddƒgg}|j|jd	ƒd
ƒ|j|jd|dƒdƒ|j|jd|dƒd
ƒ|j|jd|dddƒdƒdS(NiiiiR+tjR2t tAsA()sb(1,2,3)sa.b().csa.b().c(1,3,2,4)tds d(b, j)(RRRtNUMBERtSTRINGRR:(Rtkids((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyR-\s!-  N(RR RR:R-(((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyR4Qs
tTest_does_tree_importcBs,eZd„Zd„Zd„Zd„ZRS(cCsPtj||ƒ}|r|Sx-|jD]"}|j||ƒ}|r&|Sq&WdS(N(Rtfind_bindingRt_find_bind_rec(RR7Rtctchild((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyRDkscCs1t|ƒ}|jd|ƒ}tj|||ƒS(Ntstart(RRDRtdoes_tree_import(RtpackageR7RR((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyRHtsc	Csdddddf}xk|D]c\}}}|j|||d	|ƒ}|j|ƒ|j|||d	|ƒ}|j|ƒqWdddddddf}xk|D]c\}}}|j|||d	|ƒ}|j|ƒ|j|||d	|ƒ}|j|ƒq¥WdS(NR*sfrom a import bsa.dsfrom a.d import bsd.asfrom d.a import bsimport bsimport b, c, ds
sfrom a import atxsfrom x import asfrom x import b, c, a, dsx.bsfrom x.b import asfrom x.b import b, c, a, dsimport asimport b, c, a, d(R*R*sfrom a import b(sa.dR*sfrom a.d import b(sd.aR*sfrom d.a import b(NR*simport b(NR*simport b, c, d(R*R*sfrom a import a(RJR*sfrom x import a(RJR*sfrom x import b, c, a, d(sx.bR*sfrom x.b import a(sx.bR*sfrom x.b import b, c, a, d(NR*simport a(NR*simport b, c, a, d(RRHR%R#(RRt
failing_testsRIR7timport_tnt
passing_tests((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttry_withzs,	
	
cCs|jdƒdS(Nsdef foo():
	bar.baz()
	start=3(RO(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_in_function“s(RR RDRHRORP(((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyRBjs				tTest_find_bindingcBsìeZdd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d„Z
d„Zd	„Zd
„Z
d„Zd„Zd
„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(cCstj|t|ƒ|ƒS(N(RRCR(RR7RRI((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyRC—scCsš|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒdS(NR*sa = bs
a = [b, c, d]s	a = foo()sa = foo().foo.foo[6][foo]sfoo = asfoo = (a, b, c)(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_simple_assignmentšscCsš|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒdS(NR*s(a,) = bs(a, b, c) = [b, c, d]s(c, (d, a), b) = foo()s(a, b) = foo().foo[6][foo]s(foo, b) = (b, a)s(foo, (b, c)) = (a, b, c)(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_tuple_assignment¢scCsš|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒdS(NR*s[a] = bs[a, b, c] = [b, c, d]s[c, [d, a], b] = foo()s[a, b] = foo().foo[a][foo]s[foo, b] = (b, a)s[foo, [b, c]] = (a, b, c)(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_list_assignmentªscCsh|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒdS(NR*s	foo.a = 5s
foo[a] = 5s
foo(a) = 5s
foo(a, b) = 5(R%RC(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_invalid_assignments²scCsh|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒdS(NR*simport asimport b, c, a, dsimport bsimport b, c, d(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_simple_import¸scCsÌ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jdd	ƒƒdS(
NR*sfrom x import asfrom a import asfrom x import b, c, a, dsfrom x.b import asfrom x.b import b, c, a, dsfrom a import bsfrom a.d import bsfrom d.a import b(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_from_import¾scCsh|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒdS(NR*s
import b as asimport b as a, c, a as f, ds
import a as fsimport b, c as f, d as e(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_import_asÈscCs³|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒdS(	NR*sfrom x import b as asfrom x import g as a, d as bsfrom x.b import t as asfrom x.b import g as a, dsfrom a import b as tsfrom a.d import b as tsfrom d.a import b as t(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_from_import_asÎscCsn|j|jddƒƒ|j|jddƒƒ|j|jdddƒƒ|j|jdddƒƒdS(NR+simport bsimport b, c, dRE(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_simple_import_with_package×scCs8|j|jdddƒƒ|j|jdddƒƒ|j|jdddƒƒ|j|jdddƒƒ|j|jdddƒƒ|j|jdd	dƒƒ|j|jdd
dƒƒ|j|jdddƒƒ|j|jddd
ƒƒ|j|jddd
ƒƒ|j|jdddƒƒdS(NR*sfrom x import aRJsfrom a import asfrom x import *sfrom x import b, c, a, dsfrom x.b import asx.bsfrom x.b import *sfrom x.b import b, c, a, dsfrom a import bsfrom a.d import bsa.dsfrom d.a import bsfrom x.y import *sa.b(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_from_import_with_packageÝscCsX|j|jdddƒƒ|j|jdddƒƒ|j|jdddƒƒdS(NR*simport b.c as asb.cs
import a as ftf(R%RC(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_import_as_with_packageêscCsÈ|j|jdddƒƒ|j|jdddƒƒ|j|jdddƒƒ|j|jdddƒƒ|j|jdddƒƒ|j|jddd	ƒƒ|j|jddd
ƒƒdS(NR*sfrom x import b as aRJsfrom x import g as a, d as bsfrom x.b import t as asx.bsfrom x.b import g as a, dsfrom a import b as tR+tt(R%RC(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyt test_from_import_as_with_packageïscCsÒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒd	}|j|jd|ƒƒdS(
NR*s
def a(): passsdef a(b, c, d): passsdef a(): b = 7sdef d(b, (c, a), e): passsdef d(a=7): passsdef d(a): passsdef d(): a = 7sG
            def d():
                def a():
                    pass(R#RCR%(Rts((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_function_defûscCs|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jdd	ƒƒ|j|jdd
ƒƒ|j|jddƒƒd}|j|jd|ƒƒdS(
NR*s
class a: passsclass a(): passsclass a(b): passsclass a(b, c=8): passs
class d: passsclass d(a): passsclass d(b, a=7): passsclass d(b, *a): passsclass d(b, **a): passsclass d: a = 7sK
            class d():
                class a():
                    pass(R#RCR%(RR`((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_class_def
scCs³|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒ|j|jddƒƒdS(	NR*sfor a in r: passsfor a, b in r: passsfor (a, b) in r: passsfor c, (a,) in r: passsfor c, (a, b) in r: passsfor c in r: a = csfor c in a: pass(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_forscCsüd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒd	}|j|jd|ƒƒdS(
NsM
            for b in r:
                for a in b:
                    passR*sP
            for b in r:
                for a, c in b:
                    passsR
            for b in r:
                for (a, c) in b:
                    passsP
            for b in r:
                for (a,) in b:
                    passsU
            for b in r:
                for c, (a, d) in b:
                    passsN
            for b in r:
                for c in b:
                    a = 7sN
            for b in r:
                for c in b:
                    d = asN
            for b in r:
                for c in a:
                    d = 7(R#RCR%(RR`((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_for_nested%s cCs6|j|jddƒƒ|j|jddƒƒdS(NR*sif b in r: a = csif a in r: d = e(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_ifVscCsBd}|j|jd|ƒƒd}|j|jd|ƒƒdS(NsL
            if b in r:
                if c in d:
                    a = cR*sL
            if b in r:
                if c in d:
                    c = a(R#RCR%(RR`((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_if_nestedZscCs6|j|jddƒƒ|j|jddƒƒdS(NR*swhile b in r: a = cswhile a in r: d = e(R#RCR%(R((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyt
test_whilegscCsBd}|j|jd|ƒƒd}|j|jd|ƒƒdS(NsR
            while b in r:
                while c in d:
                    a = cR*sR
            while b in r:
                while c in d:
                    c = a(R#RCR%(RR`((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_while_nestedkscCs€d}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒdS(NsQ
            try:
                a = 6
            except:
                b = 8R*sQ
            try:
                b = 8
            except:
                a = 6sƒ
            try:
                b = 8
            except KeyError:
                pass
            except:
                a = 6sQ
            try:
                b = 8
            except:
                b = 6(R#RCR%(RR`((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_try_exceptxscCsÝd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒdS(	Ns›
            try:
                try:
                    a = 6
                except:
                    pass
            except:
                b = 8R*s›
            try:
                b = 8
            except:
                try:
                    a = 6
                except:
                    passs›
            try:
                b = 8
            except:
                try:
                    pass
                except:
                    a = 6sÕ
            try:
                try:
                    b = 8
                except KeyError:
                    pass
                except:
                    a = 6
            except:
                passsÕ
            try:
                pass
            except:
                try:
                    b = 8
                except KeyError:
                    pass
                except:
                    a = 6sQ
            try:
                b = 8
            except:
                b = 6s
            try:
                try:
                    b = 8
                except:
                    c = d
            except:
                try:
                    b = 6
                except:
                    t = 8
                except:
                    o = y(R#RCR%(RR`((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_try_except_nested—s		cCs€d}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒdS(Ns|
            try:
                c = 6
            except:
                b = 8
            finally:
                a = 9R*sR
            try:
                b = 8
            finally:
                a = 6sR
            try:
                b = 8
            finally:
                b = 6s|
            try:
                b = 8
            except:
                b = 9
            finally:
                b = 6(R#RCR%(RR`((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_try_except_finallyäscCsad}|j|jd|ƒƒd}|j|jd|ƒƒd}|j|jd|ƒƒdS(Nsú
            try:
                c = 6
            except:
                b = 8
            finally:
                try:
                    a = 9
                except:
                    b = 9
                finally:
                    c = 9R*s
            try:
                b = 8
            finally:
                try:
                    pass
                finally:
                    a = 6sž
            try:
                b = 8
            finally:
                try:
                    b = 6
                finally:
                    b = 7(R#RCR%(RR`((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_try_except_finally_nesteds		N(RR RRCRRRSRTRURVRWRXRYRZR[R]R_RaRbRcRdReRfRgRhRiRjRkRl(((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyRQ–s2						
					
							1		
		
		M	!tTest_touch_importcBs5eZd„Zd„Zd„Zd„Zd„ZRS(cCs9tdƒ}tjdd|ƒ|jt|ƒdƒdS(Ns"""foo"""
bar()tfoos"""foo"""
import foo
bar()

(RRttouch_importRRR(RR((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_after_docstring*scCs9tdƒ}tjdd|ƒ|jt|ƒdƒdS(Ns"""foo"""
import bar
bar()Rns'"""foo"""
import bar
import foo
bar()

(RRRoRRR(RR((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_after_imports/scCs9tdƒ}tjdd|ƒ|jt|ƒdƒdS(Nsbar()Rnsimport foo
bar()

(RRRoRRR(RR((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_beginning4scCs9tdƒ}tjdd|ƒ|jt|ƒdƒdS(Nsbar()thtmltescapesfrom html import escape
bar()

(RRRoRR(RR((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyRW9scCs9tdƒ}tjdd|ƒ|jt|ƒdƒdS(Nsbar()tcgisimport cgi
bar()

(RRRoRRR(RR((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_name_import>s(RR RpRqRrRWRv(((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyRm(s
				tTest_find_indentationcBseZd„Zd„ZRS(cCsQtj}tdƒ}|j||ƒdƒtdƒ}|j||ƒdƒdS(Nsnode()ut(Rtfind_indentationRR(RtfiR((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_nothingEs
	cCs‘tj}tdƒ}|j||ƒdƒ|j||jdjdjdƒdƒtdƒ}|j||jdjdjdƒdƒdS(Nsdef f():
    x()uiiiu    sdef f():
    x()
    y()(RRyRRR(RRzR((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyttest_simpleLs	+(RR R{R|(((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyRwCs	(t__doc__RxRtos.pathtostlib2to3.pytreeRRtlib2to3Rtlib2to3.fixer_utilRRRRt
lib2to3.pgen2RRtTestCaseRR!R'R)R1R4RBRQRmRw(((s3/usr/local/lib/python2.7/lib2to3/tests/test_util.pyt<module>s$"	,ÿ“

Zerion Mini Shell 1.0