Your IP : 216.73.216.52


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_scope.cpython-35.pyc



��Yf�N�@saddlZddlZddlmZmZGdd�dej�Zedkr]ej�dS)�N)�check_syntax_error�cpython_onlyc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zed-d.��Zd/d0�Zed1d2��Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(edKdL��Z)dMS)N�
ScopeTestscCsTdd�}|d�}|d�}|j|d�d�|j|d�d�dS)Ncs�fdd�}|S)Ncs�|S)N�)�y)�xr�4/opt/alt/python35/lib64/python3.5/test/test_scope.py�addersz?ScopeTests.testSimpleNesting.<locals>.make_adder.<locals>.adderr)rr	r)rr�
make_addersz0ScopeTests.testSimpleNesting.<locals>.make_adder��
�����)�assertEqual)�selfr
�inc�plus10rrr�testSimpleNesting	s
zScopeTests.testSimpleNestingcCsTdd�}|d�}|d�}|j|d�d�|j|d�d�dS)Ncs�fdd�}|�S)Ncs�fdd�}|S)Ncs�|S)Nr)r)rrrr	szNScopeTests.testExtraNesting.<locals>.make_adder2.<locals>.extra.<locals>.adderr)r	)rrr�extrasz?ScopeTests.testExtraNesting.<locals>.make_adder2.<locals>.extrar)rrr)rr�make_adder2sz0ScopeTests.testExtraNesting.<locals>.make_adder2rrr
rr)r)rrrrrrr�testExtraNestings
zScopeTests.testExtraNestingcCsTdd�}|d�}|d�}|j|d�d�|j|d�d�dS)	Ncs �fdd�}�d�|S)Ncs�|S)Nr)r)rrrr	(szEScopeTests.testSimpleAndRebinding.<locals>.make_adder3.<locals>.adderrr)rr	r)rr�make_adder3's
z6ScopeTests.testSimpleAndRebinding.<locals>.make_adder3r�	rr
rr)r)rrrrrrr�testSimpleAndRebinding%s
z!ScopeTests.testSimpleAndRebindingcsW�fdd�}d�|�}|j|d�d�d�|j|d�d�dS)Ncs�fdd�}|�S)Ncs�fdd�}|�S)Ncs�fdd�}|S)Ncs�|S)Nr)r)�global_xrrr	8szbScopeTests.testNestingGlobalNoFree.<locals>.make_adder4.<locals>.nest.<locals>.nest.<locals>.adderr)r	)rrr�nest7szSScopeTests.testNestingGlobalNoFree.<locals>.make_adder4.<locals>.nest.<locals>.nestr)r)rrrr6szEScopeTests.testNestingGlobalNoFree.<locals>.make_adder4.<locals>.nestr)r)rrr�make_adder45sz7ScopeTests.testNestingGlobalNoFree.<locals>.make_adder4rr
rrr)r)rrr	r)rr�testNestingGlobalNoFree3s		z"ScopeTests.testNestingGlobalNoFreecCsTdd�}|d�}|d�}|j|d�d�|j|d�d�dS)Ncs G�fdd�d�}|�S)Ncs"eZdZ�fdd�ZdS)zFScopeTests.testNestingThroughClass.<locals>.make_adder5.<locals>.Addercs�|S)Nr)rr)rrr�__call__IszOScopeTests.testNestingThroughClass.<locals>.make_adder5.<locals>.Adder.__call__N)�__name__�
__module__�__qualname__rr)rrr�AdderHsr#r)rr#r)rr�make_adder5Gsz7ScopeTests.testNestingThroughClass.<locals>.make_adder5rrr
rr)r)rr$rrrrr�testNestingThroughClassEs
z"ScopeTests.testNestingThroughClasscCsTdd�}|d�}|d�}|j|d�d�|j|d�d�dS)	NcSsdd�}|a|S)NcSst|S)N)�
global_nest_x)rrrrr	WszMScopeTests.testNestingPlusFreeRefToGlobal.<locals>.make_adder6.<locals>.adder)r&)rr	rrr�make_adder6Usz>ScopeTests.testNestingPlusFreeRefToGlobal.<locals>.make_adder6rr�r
rr)r)rr'rrrrr�testNestingPlusFreeRefToGlobalSs
z)ScopeTests.testNestingPlusFreeRefToGlobalcCs2dd�}|d�}|j|d�d�dS)NcSsdd�}|d�S)Ncsd��fdd�}|S)N�*cs�|S)Nr)�z)rrr�hgszEScopeTests.testNearestEnclosingScope.<locals>.f.<locals>.g.<locals>.hr)rr,r)rr�gesz:ScopeTests.testNearestEnclosingScope.<locals>.f.<locals>.gr
r)rr-rrr�fdsz/ScopeTests.testNearestEnclosingScope.<locals>.fr��/)r)rr.Z	test_funcrrr�testNearestEnclosingScopebsz$ScopeTests.testNearestEnclosingScopecsYdd���fdd�}|ddd�}|ddd	�}|j|�d
�dS)NcSs|S)Nr)rrrr�identityqsz9ScopeTests.testMixedFreevarsAndCellvars.<locals>.identitycs���fdd�}|S)Ncs3|�}����fdd�}|��|S)Ncs�����S)Nrr)�br2rr+rrr,wszHScopeTests.testMixedFreevarsAndCellvars.<locals>.f.<locals>.g.<locals>.hr)�ar3�cr,)r2rr+)r3rrr-us

z=ScopeTests.testMixedFreevarsAndCellvars.<locals>.f.<locals>.gr)rrr+r-)r2)rr+rr.tsz2ScopeTests.testMixedFreevarsAndCellvars.<locals>.frr
����')r)rr.r-r,r)r2r�testMixedFreevarsAndCellvarsos
z'ScopeTests.testMixedFreevarsAndCellvarscs�dd�}|�}|j|j�d�|j|j�d�|j|j�d�d�G�fdd�d�}|�}|j|j�d�|j|j�d�|j|j�d�dS)Ncs&d�G�fdd�d�}|�S)N�varcsFeZdZdd�Z�fdd�Zdd�Zdd�Zd	S)
z:ScopeTests.testFreeVarInMethod.<locals>.test.<locals>.TestcSsdS)N�methodr)rrrr�method_and_var�szIScopeTests.testFreeVarInMethod.<locals>.test.<locals>.Test.method_and_varcs�S)Nr)r)r=rr�test�sz?ScopeTests.testFreeVarInMethod.<locals>.test.<locals>.Test.testcSs
td�S)N�global)�str)rrrr�
actual_global�szHScopeTests.testFreeVarInMethod.<locals>.test.<locals>.Test.actual_globalcSs
t|�S)N)r@)rrrrr@�sz>ScopeTests.testFreeVarInMethod.<locals>.test.<locals>.Test.strN)r r!r"r=r>rAr@r)r=rr�Test�srBr)rBr)r=rr>�s	z,ScopeTests.testFreeVarInMethod.<locals>.testr;r<r?csFeZdZdd�Z�fdd�Zdd�Zdd�Zd	S)
z,ScopeTests.testFreeVarInMethod.<locals>.TestcSsdS)Nr<r)rrrrr=�sz;ScopeTests.testFreeVarInMethod.<locals>.Test.method_and_varcs�S)Nr)r)r=rrr>�sz1ScopeTests.testFreeVarInMethod.<locals>.Test.testcSs
td�S)Nr?)r@)rrrrrA�sz:ScopeTests.testFreeVarInMethod.<locals>.Test.actual_globalcSs
t|�S)N)r@)rrrrr@�sz0ScopeTests.testFreeVarInMethod.<locals>.Test.strN)r r!r"r=r>rAr@r)r=rrrB�srB)rr>r=rA)rr>�trBr)r=r�testFreeVarInMethod�s
		zScopeTests.testFreeVarInMethodcCsBdddd�}|j|dd�d�|j|�d�dS)Nr4�cs�fdd�}|�dS)Ncs�dS)Nr/rr)r4rr�bar�sz8ScopeTests.testCellIsKwonlyArg.<locals>.foo.<locals>.barr6r)r4rFr)r4r�foo�sz+ScopeTests.testCellIsKwonlyArg.<locals>.foor*�2�)r)rrGrrr�testCellIsKwonlyArg�szScopeTests.testCellIsKwonlyArgcCs&dd�}|j|d�d�dS)Ncs8�fdd��|dkr(�|�Std��dS)Ncs&|dkrdS|�|d�SdS)Nrrr)�n)�factrrrL�sz1ScopeTests.testRecursion.<locals>.f.<locals>.factrzx must be >= 0)�
ValueError)rr)rLrr.�s
z#ScopeTests.testRecursion.<locals>.fr8i�)r)rr.rrr�
testRecursion�szScopeTests.testRecursioncCs8t|d�t|d�t|d�t|d�dS)Nz�if 1:
            def unoptimized_clash1(strip):
                def f(s):
                    from sys import *
                    return getrefcount(s) # ambiguity: free or local
                return f
            z�if 1:
            def unoptimized_clash2():
                from sys import *
                def f(s):
                    return getrefcount(s) # ambiguity: global or local
                return f
            z�if 1:
            def unoptimized_clash2():
                from sys import *
                def g():
                    def f(s):
                        return getrefcount(s) # ambiguity: global or local
                    return f
            z�if 1:
            def f():
                def g():
                    from sys import *
                    return getrefcount # global or local?
            )r)rrrr�testUnoptimizedNamespaces�sz$ScopeTests.testUnoptimizedNamespacesc	s!dd�}|d�}|d�}|j|d�d�|j|d�d�dd�}|d�}|d�}|j|d�d�|j|d�d��fd	d�}d�|d�}|j|d�d
�dd�}|ddd
�}|ddd
�}|j|�d�dS)Ncs�fdd�S)Ncs�|S)Nr)r)rrr�<lambda>�sz:ScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>r)rr)rrrP�sz(ScopeTests.testLambdas.<locals>.<lambda>rrr
r/�cs�fdd��S)Ncs�fdd�S)Ncs�|S)Nr)r)rrrrP�szLScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>rr)rrrrP�sz:ScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>r)rr)rrrP�scs�fdd�S)Ncs�|S)Nr)r)rrrrP�sz:ScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>r)r)rrrrP�sr6cs��fdd�S)Ncs���fdd�S)Ncs���S)Nrr)r3rr+rrrP�szLScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>.<locals>.<lambda>r)r4r3r5)rr+)r3rrP�sz:ScopeTests.testLambdas.<locals>.<lambda>.<locals>.<lambda>r)rrr+r)rr+rrP�sr7r8�)r)	r�f1rr�f2Zf3Zf8r-r,r)rr�testLambdas�s$zScopeTests.testLambdascCs<dd�}dd�}|jt|�|jt|�dS)Ncs&t���fdd�}d�dS)Ncs�S)Nrr)rrr�innersz@ScopeTests.testUnboundLocal.<locals>.errorInOuter.<locals>.innerr)�print)rVr)rr�errorInOuter�s
z1ScopeTests.testUnboundLocal.<locals>.errorInOutercs#�fdd�}|�d�dS)Ncs�S)Nrr)rrrrVsz@ScopeTests.testUnboundLocal.<locals>.errorInInner.<locals>.innerrr)rVr)rr�errorInInnersz1ScopeTests.testUnboundLocal.<locals>.errorInInner)�assertRaises�UnboundLocalError�	NameError)rrXrYrrr�testUnboundLocal�szScopeTests.testUnboundLocalcCs<dd�}dd�}|jt|�|jt|�dS)Ncs)d��t���fdd�}dS)Nrcs�S)Nrr)rrrrVszIScopeTests.testUnboundLocal_AfterDel.<locals>.errorInOuter.<locals>.inner)rW)rVr)rrrXs
z:ScopeTests.testUnboundLocal_AfterDel.<locals>.errorInOutercs&�fdd�}d��|�dS)Ncs�S)Nrr)rrrrVszIScopeTests.testUnboundLocal_AfterDel.<locals>.errorInInner.<locals>.innerrr)rVr)rrrYsz:ScopeTests.testUnboundLocal_AfterDel.<locals>.errorInInner)rZr[r\)rrXrYrrr�testUnboundLocal_AfterDelsz$ScopeTests.testUnboundLocal_AfterDelcCstdd|ji�dS)Naif 1:
            global_x = 1
            def f():
                global_x += 1
            try:
                f()
            except UnboundLocalError:
                pass
            else:
                fail('scope of global_x not correctly determined')
            �fail)�execr_)rrrr�testUnboundLocal_AugAssign#s
z%ScopeTests.testUnboundLocal_AugAssigncCs[dd�}|j|ddd��d
�dd�}|j|dd	��dd	�dS)Ncs�fdd�}|S)Ncs�S)Nrr)�lstrr�returner4szIScopeTests.testComplexDefinitions.<locals>.makeReturner.<locals>.returnerr)rbrcr)rbr�makeReturner3sz7ScopeTests.testComplexDefinitions.<locals>.makeReturnerrr
r6cs�fdd�}|S)Ncs�S)Nrr)�kwargsrrrc;szJScopeTests.testComplexDefinitions.<locals>.makeReturner2.<locals>.returnerr)rercr)rer�
makeReturner2:sz8ScopeTests.testComplexDefinitions.<locals>.makeReturner2r4r()rr
r6)r)rrdrfrrr�testComplexDefinitions1sz!ScopeTests.testComplexDefinitionscCstd�dS)Na;if 1:
            # 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`)rrrr�testScopeOfGlobalStmtAsOz ScopeTests.testScopeOfGlobalStmtcs`G�fdd�d���fdd�}xtd�D]
}|�q8W|j�jd�dS)Ncs:eZdZdZ�fdd�Z�fdd�ZdS)z!ScopeTests.testLeaks.<locals>.Foorcs�jd7_dS)Nr)�count)r)�Foorr�__init__�sz*ScopeTests.testLeaks.<locals>.Foo.__init__cs�jd8_dS)Nr)ri)r)rjrr�__del__�sz)ScopeTests.testLeaks.<locals>.Foo.__del__N)r r!r"rirkrlr)rjrrrj�srjcs&����fdd�}|�dS)Ncs�S)Nrr)rrrrT�sz,ScopeTests.testLeaks.<locals>.f1.<locals>.f2r)rT)rj)rrrS�s	z ScopeTests.testLeaks.<locals>.f1�dr)�rangerri)rrS�ir)rjr�	testLeaks�s
	zScopeTests.testLeakscCstd�dS)Na�if 1:
            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`)rrrr�testClassAndGlobal�szScopeTests.testClassAndGlobalcCs[dd�}|d�d�}|jd|�|d=|j|ddddd	d
i�dS)Ncs�fdd�}|S)Ncs-�fdd�}��}�d7�t�S)Ncs�|S)Nr)r+)rrrr,�sz>ScopeTests.testLocalsFunction.<locals>.f.<locals>.g.<locals>.hr6)�locals)rr,�w)r)rrr-�s

z3ScopeTests.testLocalsFunction.<locals>.f.<locals>.gr)rr-r)rrr.�sz(ScopeTests.testLocalsFunction.<locals>.fr
r7r,rr�rsr8)�assertInr)rr.�drrr�testLocalsFunction�s
	zScopeTests.testLocalsFunctioncCsddd�}|j|d�jd�dd�}|d�j}|jd|�|jd|�dS)NcsG�fdd�d�}|S)Ncs/eZdZdZ�fdd�Ze�dS)z0ScopeTests.testLocalsClass.<locals>.f.<locals>.C�cs�S)Nr)r)rrr�m�sz2ScopeTests.testLocalsClass.<locals>.f.<locals>.C.mN)r r!r"rryrrr)rrr�C�srzr)rrzr)rrr.�sz%ScopeTests.testLocalsClass.<locals>.frrxcsG�fdd�d�}|S)Ncs7eZdZ�Z�fdd�Zee��ZdS)z0ScopeTests.testLocalsClass.<locals>.f.<locals>.Ccs�S)Nr)r)rrrry�sz2ScopeTests.testLocalsClass.<locals>.f.<locals>.C.mN)r r!r"rry�listrrr+r)rrrrz�srzr)rrzr)rrr.�srr)rrr+�assertNotInru)rr.Zvarnamesrrr�testLocalsClass�szScopeTests.testLocalsClasscskddl}|j|j|j��|jdd��d�G�fdd�d�}|j�d�dS)NrcSsdS)Nr)r4r3r5rrrrP�sz6ScopeTests.testLocalsClass_WithTrace.<locals>.<lambda>rxcs"eZdZ�fdd�ZdS)z/ScopeTests.testLocalsClass_WithTrace.<locals>.Ccs�S)Nr)r)rrrr.sz1ScopeTests.testLocalsClass_WithTrace.<locals>.C.fN)r r!r"r.r)rrrrzsrz)�sys�
addCleanup�settrace�gettracer)rr~rzr)rr�testLocalsClass_WithTrace�sz$ScopeTests.testLocalsClass_WithTracecCs8dd�}|d��}|j|j|j��dS)NcsG�fdd�d�}|S)Ncs(eZdZ�fdd�Z�ZdS)z1ScopeTests.testBoundAndFree.<locals>.f.<locals>.Ccs�S)Nr)r)rrrrysz3ScopeTests.testBoundAndFree.<locals>.f.<locals>.C.mN)r r!r"ryr4r)rrrrz
srzr)rrzr)rrr.	sz&ScopeTests.testBoundAndFree.<locals>.fr6)rr4ry)rr.Zinstrrr�testBoundAndFreeszScopeTests.testBoundAndFreecs�ddl}�fdd��dd�}Gdd�d�}|j|j|j��|j��|d|d�|jd�|jt|j�dS)Nrcs�S)Nr)r4r3r5)�tracerrrr�sz7ScopeTests.testInteractionWithTraceFunc.<locals>.tracercsK|\}�|dkrG�dkr7d|j|f��fdd�SdS)Nr�z_%s__%scs
t|��S)N)�getattr)�obj)�desrrrPszNScopeTests.testInteractionWithTraceFunc.<locals>.adaptgetter.<locals>.<lambda>)r )�name�klass�getterZkindr)r�r�adaptgetters
z<ScopeTests.testInteractionWithTraceFunc.<locals>.adaptgetterc@seZdZdS)z:ScopeTests.testInteractionWithTraceFunc.<locals>.TestClassN)r r!r"rrrr�	TestClass!sr�rGrr�)rr�)r~rr�r�rZ�	TypeError)rr~r�r�r)r�r�testInteractionWithTraceFuncs

z'ScopeTests.testInteractionWithTraceFunccCshdd�}|d�}|jtt|j�yt|ji�Wntk
rVYnX|jd�dS)Ncs�fdd�S)Ncs�dS)Nrrr)rrrrP.sz<ScopeTests.testEvalExecFreeVars.<locals>.f.<locals>.<lambda>r)rr)rrr.-sz*ScopeTests.testEvalExecFreeVars.<locals>.fr6z9exec should have failed, because code contained free vars)rZr��eval�__code__r`r_)rr.r-rrr�testEvalExecFreeVars+s
zScopeTests.testEvalExecFreeVarscCsgytt�Wntk
r"YnXtd�dd�}|�ytt�Wntk
rbYnXdS)Nzbad should not be definedcSsdd�dD�dS)NcSs)g|]}|j�D]}|�qqSr)�split)�.0�s�badrrr�
<listcomp>Ds	z?ScopeTests.testListCompLocalVars.<locals>.x.<locals>.<listcomp>za brrrrrrCsz+ScopeTests.testListCompLocalVars.<locals>.x)rWr�r\)rrrrr�testListCompLocalVars:s


z ScopeTests.testListCompLocalVarscCsdd�}|d��dS)Ncs�fdd�}|S)Ncs�td�dS)Nzx + 1)r�r)rrrr-Osz1ScopeTests.testEvalFreeVars.<locals>.f.<locals>.gr)rr-r)rrr.Nsz&ScopeTests.testEvalFreeVars.<locals>.fr7r)rr.rrr�testEvalFreeVarsLszScopeTests.testEvalFreeVarscCsGdd�d�}dS)Nc@seZdZdd�ZdS)z+ScopeTests.testFreeingCell.<locals>.SpecialcSst�dS)N)Znestedcell_get)rrrrrlZsz3ScopeTests.testFreeingCell.<locals>.Special.__del__N)r r!r"rlrrrr�SpecialYsr�r)rr�rrr�testFreeingCellVszScopeTests.testFreeingCellcCsndd�}|d�\}}|j|�d�|j|�d�|j|�d�|j|�d�dS)Ncs.�fdd�}�fdd�}||fS)Ncs�d7��S)Nrrr)rrrr`s
z7ScopeTests.testNonLocalFunction.<locals>.f.<locals>.inccs�d8��S)Nrrr)rrr�decds
z7ScopeTests.testNonLocalFunction.<locals>.f.<locals>.decr)rrr�r)rrr._sz*ScopeTests.testNonLocalFunction.<locals>.frrr
)r)rr.rr�rrr�testNonLocalFunction]szScopeTests.testNonLocalFunctioncCstdd�}|d�}|j|j�d�|j|j�d�|j|j�d�|j|j�d�dS)Ncs G�fdd�d�}|�S)Ncs4eZdZ�fdd�Z�fdd�ZdS)z3ScopeTests.testNonLocalMethod.<locals>.f.<locals>.ccs�d7��S)Nrr)r)rrrrss
z7ScopeTests.testNonLocalMethod.<locals>.f.<locals>.c.inccs�d8��S)Nrr)r)rrrr�ws
z7ScopeTests.testNonLocalMethod.<locals>.f.<locals>.c.decN)r r!r"rr�r)rrrr5rsr5r)rr5r)rrr.qs	z(ScopeTests.testNonLocalMethod.<locals>.frrr
)rrr�)rr.r5rrr�testNonLocalMethodpszScopeTests.testNonLocalMethodcCsHi}i}td||�|jd|d�|jd|d�dS)NaCif 1:
            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()
            r
Zresult2rZresult9)r`r)rZlocal_nsZ	global_nsrrr�#testGlobalInParallelNestedFunctions�s

z.ScopeTests.testGlobalInParallelNestedFunctionscCsHdd�}|d�}|j|j�d�|jd|jj�dS)Ncs G�fdd�d�}|�S)Ncs,eZdZ�d7��fdd�ZdS)z2ScopeTests.testNonLocalClass.<locals>.f.<locals>.crcs�S)Nr)r)rrr�get�sz6ScopeTests.testNonLocalClass.<locals>.f.<locals>.c.getN)r r!r"r�r)rrrr5�s
r5r)rr5r)rrr.�sz'ScopeTests.testNonLocalClass.<locals>.frrr)rr�r|�	__class__�__dict__)rr.r5rrr�testNonLocalClass�szScopeTests.testNonLocalClasscCsGdd�}|d�}|jt|d��dddddg�dS)	Ncs�fdd�}|S)Nc3s*x#t|�D]}�d7��Vq
WdS)Nr)rn)rro)rrrr-�s
z6ScopeTests.testNonLocalGenerator.<locals>.f.<locals>.gr)rr-r)rrr.�sz+ScopeTests.testNonLocalGenerator.<locals>.frr/rr
r6r7)rr{)rr.r-rrr�testNonLocalGenerator�sz ScopeTests.testNonLocalGeneratorcCs8dd�}|d�}|�}|j|�d�dS)Ncs�fdd�}|S)Ncs �d8��fdd�}|S)Nr
cs�d7��S)Nr7rr)rrrr,�s
z>ScopeTests.testNestedNonLocal.<locals>.f.<locals>.g.<locals>.hr)r,)rrrr-�s
z3ScopeTests.testNestedNonLocal.<locals>.f.<locals>.gr)rr-r)rrr.�sz(ScopeTests.testNestedNonLocal.<locals>.frr6)r)rr.r-r,rrr�testNestedNonLocal�s	zScopeTests.testNestedNonLocalcCsdd�}dd�}dS)NcSsdS)Nr)r4rrr�top�sz/ScopeTests.testTopIsNotSignificant.<locals>.topcSsdS)Nrrrrrr3�sz-ScopeTests.testTopIsNotSignificant.<locals>.br)rr�r3rrr�testTopIsNotSignificant�sz"ScopeTests.testTopIsNotSignificantcsod�G�fdd�d�}|j|jd�Gdd�d�}|jt|d��|j�d�dS)Nr*cs#eZdZde�d<�ZdS)z8ScopeTests.testClassNamespaceOverridesClosure.<locals>.X�+rN)r r!r"rrrr)rrr�X�s
r�r�c@s eZdZde�d<[dS)z8ScopeTests.testClassNamespaceOverridesClosure.<locals>.Xr�rN)r r!r"rrrrrrrr��s
r)rrZassertFalse�hasattr)rr�r)rr�"testClassNamespaceOverridesClosure�sz-ScopeTests.testClassNamespaceOverridesClosurecCsLGdd�d�}|�}|j�tj|�}~|j|��dS)Nc@seZdZdd�ZdS)z'ScopeTests.testCellLeak.<locals>.TestercsGyddWn.tk
r<}z|�_WYdd}~XnXd�dS)Nrr)�	Exception�exc)rr�r)rr�dig�s
z+ScopeTests.testCellLeak.<locals>.Tester.digN)r r!r"r�rrrr�Tester�sr�)r��weakref�refZassertIsNone)rr�Ztesterr�rrr�testCellLeak�s
		
zScopeTests.testCellLeakN)*r r!r"rrrrr%r)r1r:rDrJrNrOrUr]r^rargrhrprqrwr}rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrsL

%"T!



r�__main__)	Zunittestr�Ztest.supportrrZTestCaserr �mainrrrr�<module>s���