%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/test/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/test/test_scope.pyo

ó
Nêáac@sjddlZddlmZmZmZmZdejfd„ƒYZd„Ze	dkrfeƒndS(iÿÿÿÿN(tcheck_syntax_errortcheck_py3k_warningstcheck_warningstrun_unittestt
ScopeTestscBseZd„Zd„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„Zd„Zd„ZRS(cCsQd„}|dƒ}|dƒ}|j|dƒdƒ|j|dƒdƒdS(Ncs‡fd†}|S(Ncsˆ|S(N((ty(tx(s+/usr/local/lib/python2.7/test/test_scope.pytadders((RR((Rs+/usr/local/lib/python2.7/test/test_scope.pyt
make_adder
sii
iiþÿÿÿi(tassertEqual(tselfRtinctplus10((s+/usr/local/lib/python2.7/test/test_scope.pyttestSimpleNestings
	cCsQd„}|dƒ}|dƒ}|j|dƒdƒ|j|dƒdƒdS(Ncs‡fd†}|ƒS(Ncs‡fd†}|S(Ncsˆ|S(N((R(R(s+/usr/local/lib/python2.7/test/test_scope.pyRs((R(R(s+/usr/local/lib/python2.7/test/test_scope.pytextras((RR((Rs+/usr/local/lib/python2.7/test/test_scope.pytmake_adder2sii
iiþÿÿÿi(R	(R
RRR((s+/usr/local/lib/python2.7/test/test_scope.pyttestExtraNestings
	cCsQd„}|dƒ}|dƒ}|j|dƒdƒ|j|dƒdƒdS(Ncs‡fd†}ˆd‰|S(Ncsˆ|S(N((R(R(s+/usr/local/lib/python2.7/test/test_scope.pyR'si((RR((Rs+/usr/local/lib/python2.7/test/test_scope.pytmake_adder3&s
ii	iiiþÿÿÿi(R	(R
RRR((s+/usr/local/lib/python2.7/test/test_scope.pyttestSimpleAndRebinding$s
	csT‡fd†}d‰|ƒ}|j|dƒdƒd‰|j|dƒdƒdS(Ncs‡fd†}|ƒS(Ncs‡fd†}|ƒS(Ncs‡fd†}|S(Ncsˆ|S(N((R(tglobal_x(s+/usr/local/lib/python2.7/test/test_scope.pyR7s((R(R(s+/usr/local/lib/python2.7/test/test_scope.pytnest6s((R(R(s+/usr/local/lib/python2.7/test/test_scope.pyR5s((R(R(s+/usr/local/lib/python2.7/test/test_scope.pytmake_adder44siii
iþÿÿÿi(R	(R
RR((Rs+/usr/local/lib/python2.7/test/test_scope.pyttestNestingGlobalNoFree2s		cCsQd„}|dƒ}|dƒ}|j|dƒdƒ|j|dƒdƒdS(Ncs dd‡fd†ƒY}|ƒS(NtAddercseZ‡fd†ZRS(csˆ|S(N((R
R(R(s+/usr/local/lib/python2.7/test/test_scope.pyt__call__Hs(t__name__t
__module__R((R(s+/usr/local/lib/python2.7/test/test_scope.pyRGs(((RR((Rs+/usr/local/lib/python2.7/test/test_scope.pytmake_adder5Fsii
iiþÿÿÿi(R	(R
RRR((s+/usr/local/lib/python2.7/test/test_scope.pyttestNestingThroughClassDs
	cCsQd„}|dƒ}|dƒ}|j|dƒdƒ|j|dƒdƒdS(NcSsd„}|a|S(NcSst|S(N(t
global_nest_x(R((s+/usr/local/lib/python2.7/test/test_scope.pyRVs(R(RR((s+/usr/local/lib/python2.7/test/test_scope.pytmake_adder6Ts	ii
iiþÿÿÿi(R	(R
RRR((s+/usr/local/lib/python2.7/test/test_scope.pyttestNestingPlusFreeRefToGlobalRs
	cCs/d„}|dƒ}|j|dƒdƒdS(NcSsd„}|dƒS(Ncsd‰‡fd†}|S(Ni*csˆ|S(N((tz(R(s+/usr/local/lib/python2.7/test/test_scope.pythfs((RR!((Rs+/usr/local/lib/python2.7/test/test_scope.pytgdsi((RR"((s+/usr/local/lib/python2.7/test/test_scope.pytfcs	i
ii/(R	(R
R#t	test_func((s+/usr/local/lib/python2.7/test/test_scope.pyttestNearestEnclosingScopeas	csSd„‰‡fd†}|dddƒ}|dddƒ}|j|ƒdƒdS(	NcSs|S(N((R((s+/usr/local/lib/python2.7/test/test_scope.pytidentitypscs‡‡‡fd†}|S(Ncs0|ˆ}‡‡‡‡fd†}|ˆ‰|S(NcsˆˆˆˆƒS(N(((tbR&RR (s+/usr/local/lib/python2.7/test/test_scope.pyR!vs((taR'tcR!(R&RR (R'Rs+/usr/local/lib/python2.7/test/test_scope.pyR"ts

((RRR R"(R&(RR s+/usr/local/lib/python2.7/test/test_scope.pyR#ssiiiiii'(R	(R
R#R"R!((R&s+/usr/local/lib/python2.7/test/test_scope.pyttestMixedFreevarsAndCellvarsns
	csÂd„}|ƒ}|j|jƒdƒ|j|jƒdƒ|j|jƒdƒd‰dd‡fd†ƒY}|ƒ}|j|jƒdƒ|j|jƒdƒ|j|jƒdƒdS(Ncs&d‰dd‡fd†ƒY}|ƒS(NtvartTestcs2eZd„Z‡fd†Zd„Zd„ZRS(cSsdS(Ntmethod((R
((s+/usr/local/lib/python2.7/test/test_scope.pytmethod_and_var‡scsˆS(N((R
(R.(s+/usr/local/lib/python2.7/test/test_scope.pyttest‰scSs
tdƒS(Ntglobal(tstr(R
((s+/usr/local/lib/python2.7/test/test_scope.pyt
actual_global‹scSs
t|ƒS(N(R1(R
((s+/usr/local/lib/python2.7/test/test_scope.pyR1s(RRR.R/R2R1((R.(s+/usr/local/lib/python2.7/test/test_scope.pyR,†s		(((R,((R.s+/usr/local/lib/python2.7/test/test_scope.pyR/„s	R+R-R0R,cs2eZd„Z‡fd†Zd„Zd„ZRS(cSsdS(NR-((R
((s+/usr/local/lib/python2.7/test/test_scope.pyR.™scsˆS(N((R
(R.(s+/usr/local/lib/python2.7/test/test_scope.pyR/›scSs
tdƒS(NR0(R1(R
((s+/usr/local/lib/python2.7/test/test_scope.pyR2scSs
t|ƒS(N(R1(R
((s+/usr/local/lib/python2.7/test/test_scope.pyR1Ÿs(RRR.R/R2R1((R.(s+/usr/local/lib/python2.7/test/test_scope.pyR,—s		((R	R/R.R2(R
R/ttR,((R.s+/usr/local/lib/python2.7/test/test_scope.pyttestFreeVarInMethod‚s	
		cCs#d„}|j|dƒdƒdS(Ncs2‡fd†‰|dkr%ˆ|ƒStd‚dS(Ncs&|dkrdS|ˆ|dƒSdS(Nii((tn(tfact(s+/usr/local/lib/python2.7/test/test_scope.pyR6ªsisx must be >= 0(t
ValueError(R((R6s+/usr/local/lib/python2.7/test/test_scope.pyR#©s
iiÐ(R	(R
R#((s+/usr/local/lib/python2.7/test/test_scope.pyt
testRecursion§s	cBsZe|dƒe|dƒe|dƒe|dƒe|dƒe|dƒddUdS(NsŠdef unoptimized_clash1(strip):
    def f(s):
        from string import *
        return strip(s) # ambiguity: free or local
    return f
sƒdef unoptimized_clash2():
    from string import *
    def f(s):
        return strip(s) # ambiguity: global or local
    return f
sœdef unoptimized_clash2():
    from string import *
    def g():
        def f(s):
            return strip(s) # ambiguity: global or local
        return f
sOdef error(y):
    exec "a = 1"
    def f(x):
        return x + y
    return f
sCdef f(x):
    def g():
        return x
    del x # can't del name
s[def f():
    def g():
        from string import *
        return strip # global or local?
sç
def noproblem1():
    from string import *
    f = lambda x:x

def noproblem2():
    from string import *
    def f(x):
        return x + 1

def noproblem3():
    from string import *
    def f(x):
        global y
        y = x
(R(R
((s+/usr/local/lib/python2.7/test/test_scope.pyttestUnoptimizedNamespaces·sc	sd„}|dƒ}|dƒ}|j|dƒdƒ|j|dƒdƒd„}|dƒ}|dƒ}|j|dƒdƒ|j|dƒdƒ‡fd†}d‰|dƒ}|j|dƒd	ƒd
„}|ddd	ƒ}|dddƒ}|j|ƒd
ƒdS(Ncs
‡fd†S(Ncsˆ|S(N((R(R(s+/usr/local/lib/python2.7/test/test_scope.pyt<lambda>þt((R((Rs+/usr/local/lib/python2.7/test/test_scope.pyR:þR;ii
iiics‡fd†ƒS(Ncs
‡fd†S(Ncsˆ|S(N((R(R(s+/usr/local/lib/python2.7/test/test_scope.pyR:R;(((R(s+/usr/local/lib/python2.7/test/test_scope.pyR:R;((R((Rs+/usr/local/lib/python2.7/test/test_scope.pyR:R;cs
‡fd†S(Ncsˆ|S(N((R(R(s+/usr/local/lib/python2.7/test/test_scope.pyR:
R;((R(R(s+/usr/local/lib/python2.7/test/test_scope.pyR:
R;ics‡‡fd†S(Ncs‡‡‡fd†S(NcsˆˆˆS(N(((R'RR (s+/usr/local/lib/python2.7/test/test_scope.pyR:R;((R(R'R)(RR (R's+/usr/local/lib/python2.7/test/test_scope.pyR:R;((RRR ((RR s+/usr/local/lib/python2.7/test/test_scope.pyR:R;iii(R	tNone(	R
tf1RRtf2tf3tf8R"R!((Rs+/usr/local/lib/python2.7/test/test_scope.pyttestLambdasüs$			cBsHd„}d„}|je|ƒ|je|ƒdi|jd6UdS(NcsˆGH‡fd†}d‰dS(NcsˆS(N(((R(s+/usr/local/lib/python2.7/test/test_scope.pytinnersi((RB((Rs+/usr/local/lib/python2.7/test/test_scope.pyterrorInOuterscs ‡fd†}|ƒd‰dS(NcsˆS(N(((R(s+/usr/local/lib/python2.7/test/test_scope.pyRBsi((RB((Rs+/usr/local/lib/python2.7/test/test_scope.pyterrorInInnerss–
global_x = 1
def f():
    global_x += 1
try:
    f()
except UnboundLocalError:
    pass
else:
    fail('scope of global_x not correctly determined')
tfail(tassertRaisestUnboundLocalErrort	NameErrorRE(R
RCRD((s+/usr/local/lib/python2.7/test/test_scope.pyttestUnboundLocals
		
cBs•d„}|j|dddƒƒdƒd„}|j|ddƒƒddƒedefƒd	eƒUWdQX|jedƒdƒdƒdS(Ncs‡fd†}|S(NcsˆS(N(((tlst(s+/usr/local/lib/python2.7/test/test_scope.pytreturner5s((RJRK((RJs+/usr/local/lib/python2.7/test/test_scope.pytmakeReturner4siiics‡fd†}|S(NcsˆS(N(((tkwargs(s+/usr/local/lib/python2.7/test/test_scope.pyRK<s((RMRK((RMs+/usr/local/lib/python2.7/test/test_scope.pyt
makeReturner2;sR(is*tuple parameter unpacking has been removedscdef makeAddPair((a, b)):
    def addPair((c, d)):
        return (a + c, b + d)
    return addPair
idiÈieiÊ(iii(ii(idiÈ(ieiÊ(R	Rt
SyntaxWarningtlocalstmakeAddPair(R
RLRN((s+/usr/local/lib/python2.7/test/test_scope.pyttestComplexDefinitions2s		 
cBsddUdS(NsÉ# I
x = 7
def f():
    x = 1
    def g():
        global x
        def i():
            def h():
                return x
            return h()
        return i()
    return g()
self.assertEqual(f(), 7)
self.assertEqual(x, 7)

# II
x = 7
def f():
    x = 1
    def g():
        x = 2
        def i():
            def h():
                return x
            return h()
        return i()
    return g()
self.assertEqual(f(), 2)
self.assertEqual(x, 7)

# III
x = 7
def f():
    x = 1
    def g():
        global x
        x = 2
        def i():
            def h():
                return x
            return h()
        return i()
    return g()
self.assertEqual(f(), 2)
self.assertEqual(x, 2)

# IV
x = 7
def f():
    x = 3
    def g():
        global x
        x = 2
        def i():
            def h():
                return x
            return h()
        return i()
    return g()
self.assertEqual(f(), 2)
self.assertEqual(x, 2)

# XXX what about global statements in class blocks?
# do they affect methods?

x = 12
class Global:
    global x
    x = 13
    def set(self, val):
        x = val
    def get(self):
        return x

g = Global()
self.assertEqual(g.get(), 13)
g.set(15)
self.assertEqual(g.get(), 13)
((R
((s+/usr/local/lib/python2.7/test/test_scope.pyttestScopeOfGlobalStmtLsRcs]dd‡fd†ƒY‰‡fd†}xtdƒD]
}|ƒq5W|jˆjdƒdS(NtFoocs,eZdZ‡fd†Z‡fd†ZRS(icsˆjd7_dS(Ni(tcount(R
(RT(s+/usr/local/lib/python2.7/test/test_scope.pyt__init__¥scsˆjd8_dS(Ni(RU(R
(RT(s+/usr/local/lib/python2.7/test/test_scope.pyt__del__¨s(RRRURVRW((RT(s+/usr/local/lib/python2.7/test/test_scope.pyRT¢scs#ˆƒ‰‡fd†}|ƒdS(NcsˆS(N(((R(s+/usr/local/lib/python2.7/test/test_scope.pyR>­s((R>(RT(Rs+/usr/local/lib/python2.7/test/test_scope.pyR=«s	idi((trangeR	RU(R
R=ti((RTs+/usr/local/lib/python2.7/test/test_scope.pyt	testLeaks s
	cBsddUdS(Ns¶def test(x):
    class Foo:
        global x
        def __call__(self, y):
            return x + y
    return Foo()

x = 0
self.assertEqual(test(6)(2), 8)
x = -1
self.assertEqual(test(3)(2), 5)

looked_up_by_load_name = False
class X:
    # Implicit globals inside classes are be looked up by LOAD_NAME, not
    # LOAD_GLOBAL.
    locals()['looked_up_by_load_name'] = True
    passed = looked_up_by_load_name

self.assertTrue(X.passed)
((R
((s+/usr/local/lib/python2.7/test/test_scope.pyttestClassAndGlobal¶scCs[d„}|dƒdƒ}|jd|ƒ|d=|j|idd6dd6dd	6ƒdS(
Ncs‡fd†}|S(Ncs*‡fd†}ˆˆ}ˆd7‰tƒS(Ncsˆ|S(N((R (R(s+/usr/local/lib/python2.7/test/test_scope.pyR!Ósi(RP(RR!tw(R(Rs+/usr/local/lib/python2.7/test/test_scope.pyR"Òs

((RR"((Rs+/usr/local/lib/python2.7/test/test_scope.pyR#ÑsiiR!RiRiR\(tassertInR	(R
R#td((s+/usr/local/lib/python2.7/test/test_scope.pyttestLocalsFunctionÏs
		cCs^d„}|j|dƒjdƒd„}|dƒj}|jd|ƒ|jd|ƒdS(Ncsdd‡fd†ƒY}|S(NtCcs$eZdZ‡fd†ZeƒRS(icsˆS(N((R
(R(s+/usr/local/lib/python2.7/test/test_scope.pytmís(RRRRaRP((R(s+/usr/local/lib/python2.7/test/test_scope.pyR`ës(((RR`((Rs+/usr/local/lib/python2.7/test/test_scope.pyR#êsiicsdd‡fd†ƒY}|S(NR`cs,eZˆZ‡fd†ZeeƒƒZRS(csˆS(N((R
(R(s+/usr/local/lib/python2.7/test/test_scope.pyRa÷s(RRRRatlistRPR ((R(s+/usr/local/lib/python2.7/test/test_scope.pyR`õs(((RR`((Rs+/usr/local/lib/python2.7/test/test_scope.pyR#ôsRR(R	RR tassertNotInR](R
R#tvarnames((s+/usr/local/lib/python2.7/test/test_scope.pyttestLocalsClassßs		csdddl}|jd„ƒz3d‰dd‡fd†ƒY}|jˆdƒWd|jdƒXdS(NiÿÿÿÿcSsdS(N(R<(R(R'R)((s+/usr/local/lib/python2.7/test/test_scope.pyR:R;iR`cseZ‡fd†ZRS(csˆS(N((R
(R(s+/usr/local/lib/python2.7/test/test_scope.pyR#s(RRR#((R(s+/usr/local/lib/python2.7/test/test_scope.pyR`
s((tsystsettraceR	R<(R
RfR`((Rs+/usr/local/lib/python2.7/test/test_scope.pyttestLocalsClass_WithTracescCs5d„}|dƒƒ}|j|j|jƒƒdS(Ncsdd‡fd†ƒY}|S(NR`cseZ‡fd†ZˆZRS(csˆS(N((R
(R(s+/usr/local/lib/python2.7/test/test_scope.pyRas(RRRaR(((R(s+/usr/local/lib/python2.7/test/test_scope.pyR`s(((RR`((Rs+/usr/local/lib/python2.7/test/test_scope.pyR#si(R	R(Ra(R
R#tinst((s+/usr/local/lib/python2.7/test/test_scope.pyttestBoundAndFrees	csxddl}‡fd†‰d„}dd	d„ƒY}|jˆƒ|d|d
ƒ|jdƒ|jt|jƒdS(NiÿÿÿÿcsˆS(N((R(R'R)(ttracer(s+/usr/local/lib/python2.7/test/test_scope.pyRk"scsK|\}‰|dkrGˆdkr:d|j|f‰n‡fd†SdS(NiR;s_%s__%scs
t|ˆƒS(N(tgetattr(tobj(tdes(s+/usr/local/lib/python2.7/test/test_scope.pyR:*R;(R(tnametklasstgettertkind((Rns+/usr/local/lib/python2.7/test/test_scope.pytadaptgetter%s
t	TestClasscBseZRS((RR(((s+/usr/local/lib/python2.7/test/test_scope.pyRt,stfooiR;((iR;(RfRgR<RFt	TypeError(R
RfRsRt((Rks+/usr/local/lib/python2.7/test/test_scope.pyttestInteractionWithTraceFuncs	

cBs_d„}|dƒ}|jee|jƒy|jiUWnek
rMnX|jdƒdS(Ncs
‡fd†S(NcsˆdS(Ni(((R(s+/usr/local/lib/python2.7/test/test_scope.pyR:8R;((R((Rs+/usr/local/lib/python2.7/test/test_scope.pyR#7sis9exec should have failed, because code contained free vars(RFRvtevalt	func_codeRE(R
R#R"((s+/usr/local/lib/python2.7/test/test_scope.pyttestEvalExecFreeVars5s	
cCsSy	tGHWntk
rnXdGHd„}|ƒy	tGHWntk
rNnXdS(Nsbad should not be definedcSs.gdD]}|jƒD]}|^qqdS(Nsa b(tsplit(tstbad((s+/usr/local/lib/python2.7/test/test_scope.pyRMs(R}RH(R
R((s+/usr/local/lib/python2.7/test/test_scope.pyttestListCompLocalVarsDs	
		
cCsd„}|dƒƒdS(Ncs‡fd†}|S(NcsˆtdƒdS(Nsx + 1(Rx((R(s+/usr/local/lib/python2.7/test/test_scope.pyR"Ys((RR"((Rs+/usr/local/lib/python2.7/test/test_scope.pyR#Xsi((R
R#((s+/usr/local/lib/python2.7/test/test_scope.pyttestEvalFreeVarsVs	cs-ddd„ƒY‰‡fd†}|ƒdS(NtSpecialcBseZd„ZRS(cSstƒdS(N(tnestedcell_get(R
((s+/usr/local/lib/python2.7/test/test_scope.pyRWds(RRRW(((s+/usr/local/lib/python2.7/test/test_scope.pyR€cscs%‡fd†aˆƒf‰d‰dS(NcsˆS(N(((R)(s+/usr/local/lib/python2.7/test/test_scope.pyRisi(R((R€(R)s+/usr/local/lib/python2.7/test/test_scope.pyR#gs(((R
R#((R€s+/usr/local/lib/python2.7/test/test_scope.pyttestFreeingCell`scBsHd}i}i}|||U|jd|dƒ|jd|dƒdS(Ns¢def f():
    y = 1
    def g():
        global y
        return y
    def h():
        return y + 1
    return g, h

y = 9
g, h = f()
result9 = g()
result2 = h()
itresult2i	tresult9(R	(R
tCODEtlocal_nst	global_ns((s+/usr/local/lib/python2.7/test/test_scope.pyt#testGlobalInParallelNestedFunctionsqs
cCsd„}d„}dS(NcSsdS(N((R(((s+/usr/local/lib/python2.7/test/test_scope.pyttopŒscSsdS(N((((s+/usr/local/lib/python2.7/test/test_scope.pyR'Žs((R
R‰R'((s+/usr/local/lib/python2.7/test/test_scope.pyttestTopIsNotSignificantŠs	(RRR
RRRRRR%R*R4R8R9RARIRRRSRZR[R_ReRhRjRwRzR~RR‚RˆRŠ(((s+/usr/local/lib/python2.7/test/test_scope.pyRs8	
						
		%		E				T				!		
				
		cCs'tdtfƒttƒWdQXdS(Ns&import \* only allowed at module level(RRORR(((s+/usr/local/lib/python2.7/test/test_scope.pyt	test_main’s
t__main__(
tunittestttest.test_supportRRRRtTestCaseRR‹R(((s+/usr/local/lib/python2.7/test/test_scope.pyt<module>s"ÿÿŽ	

Zerion Mini Shell 1.0