Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_with.cpython-34.pyc

�
h fhg�@s�dZdZdZddlZddlZddlmZddlmZm	Z	ddl
mZGdd	�d	e�Zd
d�Z
Gdd
�d
e�Ze
dd��ZGdd�de�ZGdd�de�ZGdd�dej�ZGdd�de�ZGdd�deje�ZGdd�deje�ZGdd�deej�ZGdd�dej�ZGd d!�d!ej�ZGd"d#�d#ej�ZGd$d%�d%ej�Zd&d'�Zed(kr�e�ndS))z7Unit tests for the with statement specified in PEP 343.z
Mike Blandzmbland at acm dot org�N)�deque)�_GeneratorContextManager�contextmanager)�run_unittestcs:eZdZ�fdd�Zdd�Zdd�Z�S)�MockContextManagercs/t�j|�d|_d|_d|_dS)NF)�super�__init__�enter_called�exit_called�	exit_args)�self�args)�	__class__��3/opt/alt/python34/lib64/python3.4/test/test_with.pyrs		zMockContextManager.__init__cCsd|_tj|�S)NT)r	r�	__enter__)rrrrrs	zMockContextManager.__enter__cCs1d|_|||f|_tj||||�S)NT)r
rr�__exit__)r�type�value�	tracebackrrrrs	zMockContextManager.__exit__)�__name__�
__module__�__qualname__rrrrr)rrrsrcs�fdd�}|S)Ncst�||�S)N)r)r
�kwds)�funcrr�helper!sz#mock_contextmanager.<locals>.helperr)rrr)rr�mock_contextmanager src@seZdZdd�ZdS)�MockResourcecCsd|_d|_dS)NF)�yielded�stopped)rrrrr's	zMockResource.__init__N)rrrrrrrrr&srccs,t�}zd|_|VWdd|_XdS)NT)rrr)�mockrrr�mock_contextmanager_generator,s
			r!c@s4eZdZdd�Zdd�Zdd�ZdS)�NestedcGs||_d|_dS)N)�managers�entered)rr#rrrr8s	zNested.__init__c	Cs�|jdk	rtd��nt�|_g}y;x4|jD])}|j|j��|jj|�q=WWn#|jtj	��s��nYnX|S)NzContext is not reentrant)
r$�RuntimeErrorrr#�appendr�
appendleftr�sys�exc_info)r�vars�mgrrrrr<szNested.__enter__c
Gs�|}xD|jD]9}y|j|�r1d}nWqtj�}YqXqWd|_||k	r�|d|d�j|d��ndS)Nr��)NNN)r$rr(r)�with_traceback)rr)Zexr+rrrrJs
	zNested.__exit__N)rrrrrrrrrrr"6sr"c@s4eZdZdd�Zdd�Zdd�ZdS)�
MockNestedcGs/tj||�d|_d|_d|_dS)NF)r"rr	r
r)rr#rrrr[s		zMockNested.__init__cCsd|_tj|�S)NT)r	r"r)rrrrras	zMockNested.__enter__cGs"d|_||_tj||�S)NT)r
rr"r)rr)rrrres		zMockNested.__exit__N)rrrrrrrrrrr/Zsr/c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�FailureTestCasecCs dd�}|jt|�dS)NcSst�WdQXdS)N)�foorrrr�fooNotDeclaredmsz5FailureTestCase.testNameError.<locals>.fooNotDeclared)�assertRaises�	NameError)rr2rrr�
testNameErrorlszFailureTestCase.testNameErrorcs<Gdd�dt���fdd�}|jt|�dS)Nc@seZdZdd�ZdS)z;FailureTestCase.testEnterAttributeError.<locals>.LacksEntercSsdS)Nr)rrrrrrrrsszDFailureTestCase.testEnterAttributeError.<locals>.LacksEnter.__exit__N)rrrrrrrr�
LacksEnterrsr6cs��}|�WdQXdS)Nr)r1)r6rr�
fooLacksEntervs	z>FailureTestCase.testEnterAttributeError.<locals>.fooLacksEnter)�objectr3�AttributeError)rr7r)r6r�testEnterAttributeErrorqsz'FailureTestCase.testEnterAttributeErrorcs<Gdd�dt���fdd�}|jt|�dS)Nc@seZdZdd�ZdS)z9FailureTestCase.testExitAttributeError.<locals>.LacksExitcSsdS)Nr)rrrrr}szCFailureTestCase.testExitAttributeError.<locals>.LacksExit.__enter__N)rrrrrrrr�	LacksExit|sr;cs��}|�WdQXdS)Nr)r1)r;rr�fooLacksExit�s	z<FailureTestCase.testExitAttributeError.<locals>.fooLacksExit)r8r3r9)rr<r)r;r�testExitAttributeError{sz&FailureTestCase.testExitAttributeErrorcCs#dd�}|jt||�dS)NcSst|dd�dS)N�Zsingle)�compile)�srrr�shouldRaiseSyntaxError�szGFailureTestCase.assertRaisesSyntaxError.<locals>.shouldRaiseSyntaxError)r3�SyntaxError)rZcodestrrArrr�assertRaisesSyntaxError�sz'FailureTestCase.assertRaisesSyntaxErrorcCs|jd�|jd�dS)Nzwith mock as None:
  passzwith mock as (None):
  pass)rC)rrrr�testAssignmentToNoneError�s
z)FailureTestCase.testAssignmentToNoneErrorcCs|jd�dS)Nzwith mock as ():
  pass)rC)rrrr�testAssignmentToEmptyTupleError�sz/FailureTestCase.testAssignmentToEmptyTupleErrorcCs|jd�|jd�dS)Nzwith mock as None,:
  passzwith mock as (None,):
  pass)rC)rrrr�,testAssignmentToTupleOnlyContainingNoneError�s
z<FailureTestCase.testAssignmentToTupleOnlyContainingNoneErrorcCs|jd�dS)Nz%with mock as (foo, None, bar):
  pass)rC)rrrr�(testAssignmentToTupleContainingNoneError�sz8FailureTestCase.testAssignmentToTupleContainingNoneErrorcsRGdd�dt����fdd�}�jt|��j�jd�dS)Nc@s(eZdZdd�Zdd�ZdS)z4FailureTestCase.testEnterThrows.<locals>.EnterThrowscSstd��dS)NzEnter threw)r%)rrrrr�sz>FailureTestCase.testEnterThrows.<locals>.EnterThrows.__enter__cWsdS)Nr)rr
rrrr�sz=FailureTestCase.testEnterThrows.<locals>.EnterThrows.__exit__N)rrrrrrrrr�EnterThrows�srHc	s(��}d�_|�
�_WdQXdS)N)r1)Zct)rHrrr�shouldThrow�s		z4FailureTestCase.testEnterThrows.<locals>.shouldThrow)r8r3r%�assertEqualr1)rrIr)rHrr�testEnterThrows�szFailureTestCase.testEnterThrowscs<Gdd�dt���fdd�}|jt|�dS)Nc@s(eZdZdd�Zdd�ZdS)z2FailureTestCase.testExitThrows.<locals>.ExitThrowscSsdS)Nr)rrrrr�sz<FailureTestCase.testExitThrows.<locals>.ExitThrows.__enter__cWstd��dS)N�*)r%)rr
rrrr�sz;FailureTestCase.testExitThrows.<locals>.ExitThrows.__exit__N)rrrrrrrrr�
ExitThrows�srMcs���WdQXdS)Nrr)rMrrrI�s
z3FailureTestCase.testExitThrows.<locals>.shouldThrow)r8r3r%)rrIr)rMr�testExitThrows�szFailureTestCase.testExitThrowsN)
rrrr5r:r=rCrDrErFrGrKrNrrrrr0ks

r0c@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
dd�ZdS)�ContextmanagerAssertionMixincCstd�|_dS)Nztest exception)r%�TEST_EXCEPTION)rrrr�setUp�sz"ContextmanagerAssertionMixin.setUpcCs7|j|j�|j|j�|j|jd�dS)N)�
assertTruer	�assertFalser
rJr)r�mock_managerrrr�assertInWithManagerInvariants�sz:ContextmanagerAssertionMixin.assertInWithManagerInvariantscCs7|j|j�|j|j�|j|j|�dS)N)rRr	r
rJr)rrTrrrr� assertAfterWithManagerInvariants�sz=ContextmanagerAssertionMixin.assertAfterWithManagerInvariantscCs|j|d�dS)N)NNN)rV)rrTrrr�'assertAfterWithManagerInvariantsNoError�s	zDContextmanagerAssertionMixin.assertAfterWithManagerInvariantsNoErrorcCs$|j|j�|j|j�dS)N)rRrrSr)r�mock_generatorrrr�assertInWithGeneratorInvariants�sz<ContextmanagerAssertionMixin.assertInWithGeneratorInvariantscCs$|j|j�|j|j�dS)N)rRrr)rrXrrr�)assertAfterWithGeneratorInvariantsNoError�szFContextmanagerAssertionMixin.assertAfterWithGeneratorInvariantsNoErrorcCs
|j�dS)N)rP)rrrr�raiseTestException�sz/ContextmanagerAssertionMixin.raiseTestExceptionNcCs�|j|j�|j|j�|dkrX|j|jd|j�t|j�}n|j|jd|�|j|jd|�|j|jdd�dS)Nr,rr-)	rRr	r
rJrrPrZassertIsInstanceZassertIsNot)rrT�exc_typerrr�)assertAfterWithManagerInvariantsWithError�szFContextmanagerAssertionMixin.assertAfterWithManagerInvariantsWithErrorcCs$|j|j�|j|j�dS)N)rRrr)rrXrrr�+assertAfterWithGeneratorInvariantsWithError�szHContextmanagerAssertionMixin.assertAfterWithGeneratorInvariantsWithError)rrrrQrUrVrWrYrZr[r]r^rrrrrO�srOc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�NonexceptionalTestCasecCst��WdQXdS)N)r!)rrrr�testInlineGeneratorSyntax�s
z0NonexceptionalTestCase.testInlineGeneratorSyntaxcCs't�}|�WdQX|j|�dS)N)r!rW)rr rrr�testUnboundGenerator�s	z+NonexceptionalTestCase.testUnboundGeneratorc	Cs0t��}|j|�WdQX|j|�dS)N)r!rYrZ)rr1rrr�testInlineGeneratorBoundSyntax�sz5NonexceptionalTestCase.testInlineGeneratorBoundSyntaxc	Cs6d}t��}|j|�WdQX|j|�dS)N)r!rYrZ)rr1rrr�*testInlineGeneratorBoundToExistingVariable�szANonexceptionalTestCase.testInlineGeneratorBoundToExistingVariablec	Cs9t��|_|j|j�WdQX|j|j�dS)N)r!r1rYrZ)rrrr�(testInlineGeneratorBoundToDottedVariablesz?NonexceptionalTestCase.testInlineGeneratorBoundToDottedVariablec	CsPt�}|�!}|j|�|j|�WdQX|j|�|j|�dS)N)r!rYrUrZrW)rr r1rrr�testBoundGenerators		

z)NonexceptionalTestCase.testBoundGeneratorcCs�t�}|��}t�}|�;}|j|�|j|�|j|�|j|�WdQX|j|�|j|�|j|�|j|�WdQX|j|�|j|�dS)N)r!rUrYrWrZ)r�mock_ar1�mock_b�barrrr�testNestedSingleStatements
s				






z1NonexceptionalTestCase.testNestedSingleStatementsN)
rrrr`rarbrcrdrerirrrrr_�sr_c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�NestedNonexceptionalTestCasecCstt���WdQXdS)N)r"r!)rrrr�"testSingleArgInlineGeneratorSyntax sz?NestedNonexceptionalTestCase.testSingleArgInlineGeneratorSyntaxc	Cs<t�}t|��}|j|�WdQX|j|�dS)N)r!r"rUrW)r�mr1rrr�testSingleArgBoundToNonTuple$s	z9NestedNonexceptionalTestCase.testSingleArgBoundToNonTuplec	Cs<t�}t|��}|j|�WdQX|j|�dS)N)r!r"rUrW)rrlr1rrr�2testSingleArgBoundToSingleElementParenthesizedList,s	zONestedNonexceptionalTestCase.testSingleArgBoundToSingleElementParenthesizedListcCs dd�}|jt|�dS)Nc	Ss"tt���
\}}WdQXdS)N)r"r!)r1rhrrr�shouldThrowValueError5sziNestedNonexceptionalTestCase.testSingleArgBoundToMultipleElementTupleError.<locals>.shouldThrowValueError)r3�
ValueError)rrorrr�-testSingleArgBoundToMultipleElementTupleError4szJNestedNonexceptionalTestCase.testSingleArgBoundToMultipleElementTupleErrorc	CsZt�}t|�}|�|j|�|j|�WdQX|j|�|j|�dS)N)r!r/rUrW)rr�mock_nestedrrr�testSingleArgUnbound:s	

z1NestedNonexceptionalTestCase.testSingleArgUnboundc	Cs�t�}t�}t�}t|||�}|�9|j|�|j|�|j|�|j|�WdQX|j|�|j|�|j|�|j|�dS)N)r!r/rUrW)rrl�n�orrrrr�testMultipleArgUnboundCs			





z3NestedNonexceptionalTestCase.testMultipleArgUnboundc
Cs�tt�t�t��}|�D\}}}|j|�|j|�|j|�|j|�WdQX|j|�|j|�|j|�|j|�dS)N)r/r!rYrUrZrW)rrrrlrtrurrr�testMultipleArgBoundRs	





z1NestedNonexceptionalTestCase.testMultipleArgBoundN)
rrrrkrmrnrqrsrvrwrrrrrjs	rjc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�ExceptionalTestCasecsOt����fdd�}�jt|��j���j�j�dS)Nc	s=��1�_�j���j�j��j�WdQXdS)N)�resourcerUrYr[r)�cmrrrrIcs
z;ExceptionalTestCase.testSingleResource.<locals>.shouldThrow)r!r3r%r]r^ry)rrIr)rzrr�testSingleResourceas
	
z&ExceptionalTestCase.testSingleResourcecsBt����fdd�}�jt|��j�t�dS)Nc	s���_ddWdQXdS)Nr,r)ryr)rzrrrrInsz@ExceptionalTestCase.testExceptionNormalized.<locals>.shouldThrow)r!r3�ZeroDivisionErrorr])rrIr)rzrr�testExceptionNormalizedls	z+ExceptionalTestCase.testExceptionNormalizedcsxt��t�����fdd�}�jt|��j���j���j�j��j�j�dS)Ncsl��`�_��N�_�j���j���j�j��j�j��j�WdQXWdQXdS)N)r1rhrUrYr[r)rfrgrrrrIys

zCExceptionalTestCase.testNestedSingleStatements.<locals>.shouldThrow)r!r3r%r]r^r1rh)rrIr)rfrgrrrivs		

z.ExceptionalTestCase.testNestedSingleStatementscs�t��t��t��������fdd�}�jt|��j���j���j���j�j��j�j�dS)Nc
sp��d\�_�_�j���j���j���j�j��j�j��j�WdQXdS)N)�
resource_a�
resource_brUrYr[r)�cm_a�cm_brrrrrrI�s


zOExceptionalTestCase.testMultipleResourcesInSingleStatement.<locals>.shouldThrow)r!r/r3r%r]r^r~r)rrIr)r�r�rrrr�&testMultipleResourcesInSingleStatement�s		


z:ExceptionalTestCase.testMultipleResourcesInSingleStatementcs�t��t��d�_���fdd�}�jt|��j���j�j��j�jd��j�j	��j�j
��j�jd�dS)NcsO��C�_�j���j�j��j���
�_WdQXWdQXdS)N)r1rUrYr[rhr)rfrgrrrrI�s

zPExceptionalTestCase.testNestedExceptionBeforeInnerStatement.<locals>.shouldThrow)r!rhr3r%r]r^r1rJrSr	r
r)rrIr)rfrgrr�'testNestedExceptionBeforeInnerStatement�s			
z;ExceptionalTestCase.testNestedExceptionBeforeInnerStatementcsxt��t�����fdd�}�jt|��j���j���j�j��j�j�dS)Ncsl��`�_��D�_�j���j���j�j��j�j�WdQX�j�WdQXdS)N)r1rhrUrYr[r)rfrgrrrrI�s

zOExceptionalTestCase.testNestedExceptionAfterInnerStatement.<locals>.shouldThrow)	r!r3r%r]rWr^r1rZrh)rrIr)rfrgrr�&testNestedExceptionAfterInnerStatement�s		

z:ExceptionalTestCase.testNestedExceptionAfterInnerStatementcs8tdd����fdd�}|jt|�dS)Ncss	dVdS)Nrrrrrrz�sz8ExceptionalTestCase.testRaisedStopIteration1.<locals>.cmc	s ���td��WdQXdS)Nz	from with)�
StopIterationr)rzrrrI�s
zAExceptionalTestCase.testRaisedStopIteration1.<locals>.shouldThrow)rr3r�)rrIr)rzr�testRaisedStopIteration1�sz,ExceptionalTestCase.testRaisedStopIteration1cs<Gdd�dt���fdd�}|jt|�dS)Nc@s(eZdZdd�Zdd�ZdS)z8ExceptionalTestCase.testRaisedStopIteration2.<locals>.cmcSsdS)Nr)rrrrr�szBExceptionalTestCase.testRaisedStopIteration2.<locals>.cm.__enter__cSsdS)Nr)rrrrrrrr�szAExceptionalTestCase.testRaisedStopIteration2.<locals>.cm.__exit__N)rrrrrrrrrrz�srzc	s ���td��WdQXdS)Nz	from with)r�r)rzrrrI�s
zAExceptionalTestCase.testRaisedStopIteration2.<locals>.shouldThrow)r8r3r�)rrIr)rzr�testRaisedStopIteration2�sz,ExceptionalTestCase.testRaisedStopIteration2cs8tdd����fdd�}|jt|�dS)Ncss	dVdS)Nrrrrrrz�sz8ExceptionalTestCase.testRaisedStopIteration3.<locals>.cmc
s&���ttg���WdQXdS)N)�next�iterr)rzrrrI�s
zAExceptionalTestCase.testRaisedStopIteration3.<locals>.shouldThrow)rr3r�)rrIr)rzr�testRaisedStopIteration3�sz,ExceptionalTestCase.testRaisedStopIteration3cs8tdd����fdd�}|jt|�dS)Ncss	dVdS)Nrrrrrrz�sz8ExceptionalTestCase.testRaisedGeneratorExit1.<locals>.cmc	s ���td��WdQXdS)Nz	from with)�
GeneratorExitr)rzrrrI�s
zAExceptionalTestCase.testRaisedGeneratorExit1.<locals>.shouldThrow)rr3r�)rrIr)rzr�testRaisedGeneratorExit1�sz,ExceptionalTestCase.testRaisedGeneratorExit1cs<Gdd�dt���fdd�}|jt|�dS)Nc@s(eZdZdd�Zdd�ZdS)z8ExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cmcSsdS)Nr)rrrrr�szBExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cm.__enter__cSsdS)Nr)rrrrrrrr�szAExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cm.__exit__N)rrrrrrrrrrz�srzc	s ���td��WdQXdS)Nz	from with)r�r)rzrrrI�s
zAExceptionalTestCase.testRaisedGeneratorExit2.<locals>.shouldThrow)r8r3r�)rrIr)rzr�testRaisedGeneratorExit2�sz,ExceptionalTestCase.testRaisedGeneratorExit2cs�Gdd�dt����fdd�}|���fdd�}�jt|���fdd�}�jt|�dS)	Nc@s4eZdZdd�Zdd�Zdd�ZdS)z0ExceptionalTestCase.testErrorsInBool.<locals>.cmcs)G�fdd�d�}|�|_dS)Ncs"eZdZ�fdd�ZdS)zGExceptionalTestCase.testErrorsInBool.<locals>.cm.__init__.<locals>.Boolcs��S)Nr)r)�bool_conversionrr�__bool__szPExceptionalTestCase.testErrorsInBool.<locals>.cm.__init__.<locals>.Bool.__bool__N)rrrr�r)r�rr�Boolsr�)�exit_result)rr�r�r)r�rrsz9ExceptionalTestCase.testErrorsInBool.<locals>.cm.__init__cSsdS)N�r)rrrrrsz:ExceptionalTestCase.testErrorsInBool.<locals>.cm.__enter__cSs|jS)N)r�)r�a�b�crrrr
sz9ExceptionalTestCase.testErrorsInBool.<locals>.cm.__exit__N)rrrrrrrrrrrzsrzc	s*�dd����jd�WdQXdS)NcSsdS)NTrrrrr�<lambda>szJExceptionalTestCase.testErrorsInBool.<locals>.trueAsBool.<locals>.<lambda>zShould NOT see this)�failr)rzrrr�
trueAsBoolsz8ExceptionalTestCase.testErrorsInBool.<locals>.trueAsBoolc	s*�dd����jd�WdQXdS)NcSsdS)NFrrrrrr�szKExceptionalTestCase.testErrorsInBool.<locals>.falseAsBool.<locals>.<lambda>zShould raise)r�r)rzrrr�falseAsBoolsz9ExceptionalTestCase.testErrorsInBool.<locals>.falseAsBoolc	s*�dd����jd�WdQXdS)NcSsddS)Nr,rrrrrrr�szJExceptionalTestCase.testErrorsInBool.<locals>.failAsBool.<locals>.<lambda>zShould NOT see this)r�r)rzrrr�
failAsBoolsz8ExceptionalTestCase.testErrorsInBool.<locals>.failAsBool)r8r3�AssertionErrorr|)rr�r�r�r)rzrr�testErrorsInBoolsz$ExceptionalTestCase.testErrorsInBoolN)rrrr{r}rir�r�r�r�r�r�r�r�r�rrrrrx`s

rxc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�NonLocalFlowControlTestCasec	CsPd}x3|d7}t��|d7}PWdQX|d7}q	W|j|d�dS)Nrr,�
�d�)r!rJ)r�counterrrr�
testWithBreak"s


z)NonLocalFlowControlTestCase.testWithBreakc	Csbd}xE|d7}|dkr#Pnt��|d7}w	WdQX|d7}q	W|j|d�dS)Nrr,r-r�r��)r!rJ)rr�rrr�testWithContinue,s


	z,NonLocalFlowControlTestCase.testWithContinuecCs#dd�}|j|�d�dS)Nc	SsCd}x6|d7}t��|d7}|SWdQX|d7}q	WdS)Nrr,r�r�)r!)r�rrrr19s



z7NonLocalFlowControlTestCase.testWithReturn.<locals>.foor�)rJ)rr1rrr�testWithReturn8sz*NonLocalFlowControlTestCase.testWithReturncCs5dd�}t|��}|j|ddg�dS)Ncsst��dVdVWdQXdS)Nr��
)r!rrrr�genDs
z6NonLocalFlowControlTestCase.testWithYield.<locals>.genr�r�)�listrJ)rr��xrrr�
testWithYieldCsz)NonLocalFlowControlTestCase.testWithYieldcCstd}y8|d7}t��|d7}t�WdQX|d7}Wn"tk
rb|j|d�YnX|jd�dS)Nrr,r�r�r�zDidn't raise RuntimeError)r!r%rJr�)rr�rrr�
testWithRaiseKs



z)NonLocalFlowControlTestCase.testWithRaiseN)rrrr�r�r�r�r�rrrrr� s

r�c@s(eZdZdd�Zdd�ZdS)�AssignmentTargetTestCasecCs`idddgd6}t��I|dd<|jt|j��dg�|j|ddjt�WdQXt��Ut|j��dd<|jt|j��dg�|j|ddjt�WdQXt��=|d<t|j��}|j�|j|ddg�WdQXGdd�d�}|�}t��#|_|jt	|d�d�WdQXdS)Nrr,r-c@seZdZdS)z;AssignmentTargetTestCase.testSingleComplexTarget.<locals>.CN)rrrrrrr�Cgsr�r1T)
r!rJr��keysrr�values�sortr1�hasattr)r�targetsr�r��blahrrr�testSingleComplexTarget[s! !
	z0AssignmentTargetTestCase.testSingleComplexTargetcCs�Gdd�d�}idddgd6}|��H\|dd<|dd<|dd<|j|idddgd6�WdQX|��l\t|j��dd<t|j��dd<t|j��dd<|j|idddgd6�WdQX|��A\|d<|d<|d<|j|idd6dd6dd6�WdQXGdd�d�}|�}|��R\|_|_|_|j|jd�|j|jd�|j|jd�WdQXdS)	Nc@s(eZdZdd�Zdd�ZdS)z>AssignmentTargetTestCase.testMultipleComplexTargets.<locals>.CcSsdS)Nr,r-r�)r,r-r�r)rrrrrnszHAssignmentTargetTestCase.testMultipleComplexTargets.<locals>.C.__enter__cSsdS)Nr)r�t�v�tbrrrroszGAssignmentTargetTestCase.testMultipleComplexTargets.<locals>.C.__exit__N)rrrrrrrrrr�msr�rr,r-r�c@seZdZdS)z>AssignmentTargetTestCase.testMultipleComplexTargets.<locals>.BN)rrrrrrr�Bwsr�)rJr�r�ZoneZtwoZthree)rr�r�r�r�rrr�testMultipleComplexTargetsls-&Q&!+	z3AssignmentTargetTestCase.testMultipleComplexTargetsN)rrrr�r�rrrrr�Ysr�c@s(eZdZdd�Zdd�ZdS)�ExitSwallowsExceptionTestCasecCsUGdd�d�}y|��
ddWdQXWntk
rP|jd�YnXdS)Nc@s(eZdZdd�Zdd�ZdS)zSExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallowcSsdS)Nr)rrrrr�sz]ExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallow.__enter__cSsdS)NTr)rr�r�r�rrrr�sz\ExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallow.__exit__N)rrrrrrrrr�AfricanSwallow�sr�r,rz,ZeroDivisionError should have been swallowed)r|r�)rr�rrr�testExitTrueSwallowsException�s

z;ExitSwallowsExceptionTestCase.testExitTrueSwallowsExceptioncCsUGdd�d�}y|��
ddWdQXWntk
rCYnX|jd�dS)Nc@s(eZdZdd�Zdd�ZdS)zZExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallowcSsdS)Nr)rrrrr�szdExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallow.__enter__cSsdS)NFr)rr�r�r�rrrr�szcExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallow.__exit__N)rrrrrrrrr�EuropeanSwallow�sr�r,rz)ZeroDivisionError should have been raised)r|r�)rr�rrr�#testExitFalseDoesntSwallowException�s

zAExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowExceptionN)rrrr�r�rrrrr�s
r�c@s�eZdZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)�
NestedWithc@s:eZdZdddd�Zdd�Zdd�ZdS)	zNestedWith.DummyNFcCs=|dkr|}n||_||_d|_d|_dS)NF)r�gobbler	r
)rrr�rrrr�s				zNestedWith.Dummy.__init__cCsd|_|jS)NT)r	r)rrrrr�s	zNestedWith.Dummy.__enter__cGs#d|_||_|jrdSdS)NT)r
r)r�)rr)rrrr�s			zNestedWith.Dummy.__exit__)rrrrrrrrrr�Dummy�sr�c@seZdZdd�ZdS)zNestedWith.InitRaisescCs
t��dS)N)r%)rrrrr�szNestedWith.InitRaises.__init__N)rrrrrrrr�
InitRaises�sr�c@s(eZdZdd�Zdd�ZdS)zNestedWith.EnterRaisescCs
t��dS)N)r%)rrrrr�sz NestedWith.EnterRaises.__enter__cGsdS)Nr)rr)rrrr�szNestedWith.EnterRaises.__exit__N)rrrrrrrrr�EnterRaises�sr�c@s(eZdZdd�Zdd�ZdS)zNestedWith.ExitRaisescCsdS)Nr)rrrrr�szNestedWith.ExitRaises.__enter__cGs
t��dS)N)r%)rr)rrrr�szNestedWith.ExitRaises.__exit__N)rrrrrrrrr�
ExitRaises�sr�cCsn|j��<}|j��'}|j|j�|j|j�WdQXWdQX|j|j�|j|j�dS)N)r�rRr	r
)rr�r�rrr�testNoExceptions�s
zNestedWith.testNoExceptionscCs[y,|j��}|j��WdQXWdQXWnYnX|j|j�|j|j�dS)N)r�r�rRr	r
)rr�rrr�testExceptionInExprList�sz"NestedWith.testExceptionInExprListcCsy9|j��'}|j��|jd�WdQXWdQXWntk
rMYnX|jd�|j|j�|j|j�dS)Nzbody of bad with executedzRuntimeError not reraised)r�r�r�r%rRr	r
)rr�rrr�testExceptionInEnter�s

zNestedWith.testExceptionInEntercCs�d}|jdd�� }|j��d}WdQXWdQX|j|j�|j|j�|j|�|j|jdd�dS)NFr�Tr)r�r�rRr	r
ZassertNotEqualr))rZ
body_executedr�rrr�testExceptionInExit�s"
zNestedWith.testExceptionInExitcCs�|jdd��n\}}|jdd��M\}}|jd|�|jd|�|jd|�|jd|�WdQXWdQXdS)Nrr,r-r��)r,r-)r�r�)r�rJ)rZa1Za2Zb1Zb2rrr�testEnterReturnsTuple�sz NestedWith.testEnterReturnsTupleN)
rrrr8r�r�r�r�r�r�r�r�r�rrrrr��s		r�c	Cs#ttttttttt�dS)N)	rr0r_rjrxr�r�r�r�rrrr�	test_main�s	r��__main__)�__doc__�
__author__Z	__email__r(Zunittest�collectionsr�
contextlibrrZtest.supportrrrr8rr!r"r/ZTestCaser0rOr_rjrxr�r�r�r�r�rrrrr�<module>s4
$O/5	A�9&L