Your IP : 216.73.216.213


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



���]�f�@s�dZdZddlZddlZddlmZddlmZmZGdd�de�Z	dd	�Z
Gd
d�de�Ze
dd
��Z
Gdd�de�ZGdd�de�ZGdd�dej�ZGdd�de�ZGdd�deje�ZGdd�deje�ZGdd�deej�ZGdd�dej�ZGdd�dej�ZGd d!�d!ej�ZGd"d#�d#ej�Zed$kr�ej�dS)%z
Mike Blandzmbland at acm dot org�N)�deque)�_GeneratorContextManager�contextmanagercs: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__��./opt/alt/python35/lib64/python3.5/test_with.pyrs		zMockContextManager.__init__cCsd|_tj|�S)NT)rr�	__enter__)rrrrrs	zMockContextManager.__enter__cCs1d|_|||f|_tj||||�S)NT)r	r
r�__exit__)r�type�value�	tracebackrrrrs	zMockContextManager.__exit__)�__name__�
__module__�__qualname__rrrrr)r
rr
srcs�fdd�}|S)Ncst�||�S)N)r)r�kwds)�funcrr�helper sz#mock_contextmanager.<locals>.helperr)rrr)rr�mock_contextmanagersrc@seZdZdd�ZdS)�MockResourcecCsd|_d|_dS)NF)�yielded�stopped)rrrrr&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)rr"rrrr7s	zNested.__init__c	Cs�|jdk	rtd��t�|_g}y;x4|jD])}|j|j��|jj|�q:WWn |jtj	��s��YnX|S)NzContext is not reentrant)
r#�RuntimeErrorrr"�appendr�
appendleftr�sys�exc_info)r�vars�mgrrrrr;szNested.__enter__c
Gs�|}xA|jD]6}y|j|�r.d}Wqtj�}YqXqWd|_||k	r�|d|d�j|d��dS)Nr��)NNN)r#rr'r(�with_traceback)rr(�exr*rrrrIs
	zNested.__exit__N)rrrrrrrrrrr!5sr!c@s4eZdZdd�Zdd�Zdd�ZdS)�
MockNestedcGs/tj||�d|_d|_d|_dS)NF)r!rrr	r
)rr"rrrrZs		zMockNested.__init__cCsd|_tj|�S)NT)rr!r)rrrrr`s	zMockNested.__enter__cGs"d|_||_tj||�S)NT)r	r
r!r)rr(rrrrds		zMockNested.__exit__N)rrrrrrrrrrr/Ysr/c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�FailureTestCasecCs dd�}|jt|�dS)Nc	Sst�WdQRXdS)N)�foorrrr�fooNotDeclaredlsz5FailureTestCase.testNameError.<locals>.fooNotDeclared)�assertRaises�	NameError)rr2rrr�
testNameErrorkszFailureTestCase.testNameErrorcs<Gdd�dt���fdd�}|jt|�dS)Nc@seZdZdd�ZdS)z;FailureTestCase.testEnterAttributeError.<locals>.LacksEntercSsdS)Nr)rrrrrrrrrszDFailureTestCase.testEnterAttributeError.<locals>.LacksEnter.__exit__N)rrrrrrrr�
LacksEnterqsr6c	s��}|�WdQRXdS)Nr)r1)r6rr�
fooLacksEnterus	z>FailureTestCase.testEnterAttributeError.<locals>.fooLacksEnter)�objectr3�AttributeError)rr7r)r6r�testEnterAttributeErrorpsz'FailureTestCase.testEnterAttributeErrorcs<Gdd�dt���fdd�}|jt|�dS)Nc@seZdZdd�ZdS)z9FailureTestCase.testExitAttributeError.<locals>.LacksExitcSsdS)Nr)rrrrr|szCFailureTestCase.testExitAttributeError.<locals>.LacksExit.__enter__N)rrrrrrrr�	LacksExit{sr;c	s��}|�WdQRXdS)Nr)r1)r;rr�fooLacksExits	z<FailureTestCase.testExitAttributeError.<locals>.fooLacksExit)r8r3r9)rr<r)r;r�testExitAttributeErrorzsz&FailureTestCase.testExitAttributeErrorcCs#dd�}|jt||�dS)NcSst|dd�dS)N�Zsingle)�compile)�srrr�shouldRaiseSyntaxError�szGFailureTestCase.assertRaisesSyntaxError.<locals>.shouldRaiseSyntaxError)r3�SyntaxError)rZcodestrrArrr�assertRaisesSyntaxError�sz'FailureTestCase.assertRaisesSyntaxErrorcCs|jd�|jd�dS)Nzwith mock as None:
  passzwith mock as (None):
  pass)rC)rrrr�testAssignmentToNoneError�s
z)FailureTestCase.testAssignmentToNoneErrorcCs|jd�dS)Nzwith mock as ():
  pass)rC)rrrr�testAssignmentToEmptyTupleError�sz/FailureTestCase.testAssignmentToEmptyTupleErrorcCs|jd�|jd�dS)Nzwith mock as None,:
  passzwith mock as (None,):
  pass)rC)rrrr�,testAssignmentToTupleOnlyContainingNoneError�s
z<FailureTestCase.testAssignmentToTupleOnlyContainingNoneErrorcCs|jd�dS)Nz%with mock as (foo, None, bar):
  pass)rC)rrrr�(testAssignmentToTupleContainingNoneError�sz8FailureTestCase.testAssignmentToTupleContainingNoneErrorcsRGdd�dt����fdd�}�jt|��j�jd�dS)Nc@s(eZdZdd�Zdd�ZdS)z4FailureTestCase.testEnterThrows.<locals>.EnterThrowscSstd��dS)NzEnter threw)r$)rrrrr�sz>FailureTestCase.testEnterThrows.<locals>.EnterThrows.__enter__cWsdS)Nr)rrrrrr�sz=FailureTestCase.testEnterThrows.<locals>.EnterThrows.__exit__N)rrrrrrrrr�EnterThrows�srHc	s)��}d�_|�
�_WdQRXdS)N)r1)�ct)rHrrr�shouldThrow�s		z4FailureTestCase.testEnterThrows.<locals>.shouldThrow)r8r3r$�assertEqualr1)rrJr)rHrr�testEnterThrows�szFailureTestCase.testEnterThrowscs<Gdd�dt���fdd�}|jt|�dS)Nc@s(eZdZdd�Zdd�ZdS)z2FailureTestCase.testExitThrows.<locals>.ExitThrowscSsdS)Nr)rrrrr�sz<FailureTestCase.testExitThrows.<locals>.ExitThrows.__enter__cWstd��dS)N�*)r$)rrrrrr�sz;FailureTestCase.testExitThrows.<locals>.ExitThrows.__exit__N)rrrrrrrrr�
ExitThrows�srNc	s���WdQRXdS)Nrr)rNrrrJ�s
z3FailureTestCase.testExitThrows.<locals>.shouldThrow)r8r3r$)rrJr)rNr�testExitThrows�szFailureTestCase.testExitThrowsN)
rrrr5r:r=rCrDrErFrGrLrOrrrrr0js

r0c@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
dd�ZdS)�ContextmanagerAssertionMixincCstd�|_dS)Nztest exception)r$�TEST_EXCEPTION)rrrr�setUp�sz"ContextmanagerAssertionMixin.setUpcCs7|j|j�|j|j�|j|jd�dS)N)�
assertTruer�assertFalser	rKr
)r�mock_managerrrr�assertInWithManagerInvariants�sz:ContextmanagerAssertionMixin.assertInWithManagerInvariantscCs7|j|j�|j|j�|j|j|�dS)N)rSrr	rKr
)rrUr
rrr� assertAfterWithManagerInvariants�sz=ContextmanagerAssertionMixin.assertAfterWithManagerInvariantscCs|j|d�dS)N)NNN)rW)rrUrrr�'assertAfterWithManagerInvariantsNoError�s	zDContextmanagerAssertionMixin.assertAfterWithManagerInvariantsNoErrorcCs$|j|j�|j|j�dS)N)rSrrTr)r�mock_generatorrrr�assertInWithGeneratorInvariants�sz<ContextmanagerAssertionMixin.assertInWithGeneratorInvariantscCs$|j|j�|j|j�dS)N)rSrr)rrYrrr�)assertAfterWithGeneratorInvariantsNoError�szFContextmanagerAssertionMixin.assertAfterWithGeneratorInvariantsNoErrorcCs
|j�dS)N)rQ)rrrr�raiseTestException�sz/ContextmanagerAssertionMixin.raiseTestExceptionNcCs�|j|j�|j|j�|dkrU|j|jd|j�t|j�}|j|jd|�|j|jd|�|j|jdd�dS)Nr+rr,)	rSrr	rKr
rQrZassertIsInstanceZassertIsNot)rrU�exc_typerrr�)assertAfterWithManagerInvariantsWithError�szFContextmanagerAssertionMixin.assertAfterWithManagerInvariantsWithErrorcCs$|j|j�|j|j�dS)N)rSrr)rrYrrr�+assertAfterWithGeneratorInvariantsWithError�szHContextmanagerAssertionMixin.assertAfterWithGeneratorInvariantsWithError)rrrrRrVrWrXrZr[r\r^r_rrrrrP�srPc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�NonexceptionalTestCasec	Cst��WdQRXdS)N)r )rrrr�testInlineGeneratorSyntax�s
z0NonexceptionalTestCase.testInlineGeneratorSyntaxc	Cs(t�}|�WdQRX|j|�dS)N)r rX)rrrrr�testUnboundGenerator�s	z+NonexceptionalTestCase.testUnboundGeneratorc	Cs1t��}|j|�WdQRX|j|�dS)N)r rZr[)rr1rrr�testInlineGeneratorBoundSyntax�sz5NonexceptionalTestCase.testInlineGeneratorBoundSyntaxc	Cs7d}t��}|j|�WdQRX|j|�dS)N)r rZr[)rr1rrr�*testInlineGeneratorBoundToExistingVariable�szANonexceptionalTestCase.testInlineGeneratorBoundToExistingVariablec	Cs:t��|_|j|j�WdQRX|j|j�dS)N)r r1rZr[)rrrr�(testInlineGeneratorBoundToDottedVariable�sz?NonexceptionalTestCase.testInlineGeneratorBoundToDottedVariablec	CsQt�}|�!}|j|�|j|�WdQRX|j|�|j|�dS)N)r rZrVr[rX)rrr1rrr�testBoundGenerators		

z)NonexceptionalTestCase.testBoundGeneratorcCs�t�}|��}t�}|�;}|j|�|j|�|j|�|j|�WdQRX|j|�|j|�|j|�|j|�WdQRX|j|�|j|�dS)N)r rVrZrXr[)r�mock_ar1�mock_b�barrrr�testNestedSingleStatementss				






z1NonexceptionalTestCase.testNestedSingleStatementsN)
rrrrarbrcrdrerfrjrrrrr`�sr`c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�NestedNonexceptionalTestCasec	Cstt���WdQRXdS)N)r!r )rrrr�"testSingleArgInlineGeneratorSyntaxsz?NestedNonexceptionalTestCase.testSingleArgInlineGeneratorSyntaxc	Cs=t�}t|��}|j|�WdQRX|j|�dS)N)r r!rVrX)r�mr1rrr�testSingleArgBoundToNonTuple#s	z9NestedNonexceptionalTestCase.testSingleArgBoundToNonTuplec	Cs=t�}t|��}|j|�WdQRX|j|�dS)N)r r!rVrX)rrmr1rrr�2testSingleArgBoundToSingleElementParenthesizedList+s	zONestedNonexceptionalTestCase.testSingleArgBoundToSingleElementParenthesizedListcCs dd�}|jt|�dS)Nc	Ss#tt���
\}}WdQRXdS)N)r!r )r1rirrr�shouldThrowValueError4sziNestedNonexceptionalTestCase.testSingleArgBoundToMultipleElementTupleError.<locals>.shouldThrowValueError)r3�
ValueError)rrprrr�-testSingleArgBoundToMultipleElementTupleError3szJNestedNonexceptionalTestCase.testSingleArgBoundToMultipleElementTupleErrorc	Cs[t�}t|�}|�|j|�|j|�WdQRX|j|�|j|�dS)N)r r/rVrX)rr�mock_nestedrrr�testSingleArgUnbound9s	

z1NestedNonexceptionalTestCase.testSingleArgUnboundc	Cs�t�}t�}t�}t|||�}|�9|j|�|j|�|j|�|j|�WdQRX|j|�|j|�|j|�|j|�dS)N)r r/rVrX)rrm�n�orsrrr�testMultipleArgUnboundBs			





z3NestedNonexceptionalTestCase.testMultipleArgUnboundc
Cs�tt�t�t��}|�D\}}}|j|�|j|�|j|�|j|�WdQRX|j|�|j|�|j|�|j|�dS)N)r/r rZrVr[rX)rrsrmrurvrrr�testMultipleArgBoundQs	





z1NestedNonexceptionalTestCase.testMultipleArgBoundN)
rrrrlrnrorrrtrwrxrrrrrks	rkc@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�WdQRXdS)N)�resourcerVrZr\r)�cmrrrrJbs
z;ExceptionalTestCase.testSingleResource.<locals>.shouldThrow)r r3r$r^r_rz)rrJr)r{rr�testSingleResource`s
	
z&ExceptionalTestCase.testSingleResourcecsBt����fdd�}�jt|��j�t�dS)Nc	s���_ddWdQRXdS)Nr+r)rzr)r{rrrrJmsz@ExceptionalTestCase.testExceptionNormalized.<locals>.shouldThrow)r r3�ZeroDivisionErrorr^)rrJr)r{rr�testExceptionNormalizedks	z+ExceptionalTestCase.testExceptionNormalizedcsxt��t�����fdd�}�jt|��j���j���j�j��j�j�dS)Ncsn��a�_��N�_�j���j���j�j��j�j��j�WdQRXWdQRXdS)N)r1rirVrZr\r)rgrhrrrrJxs

zCExceptionalTestCase.testNestedSingleStatements.<locals>.shouldThrow)r r3r$r^r_r1ri)rrJr)rgrhrrrjus		

z.ExceptionalTestCase.testNestedSingleStatementscs�t��t��t��������fdd�}�jt|��j���j���j���j�j��j�j�dS)Nc
sq��d\�_�_�j���j���j���j�j��j�j��j�WdQRXdS)N)�
resource_a�
resource_brVrZr\r)�cm_a�cm_brsrrrrJ�s


zOExceptionalTestCase.testMultipleResourcesInSingleStatement.<locals>.shouldThrow)r r/r3r$r^r_rr�)rrJr)r�r�rsrr�&testMultipleResourcesInSingleStatement�s		


z:ExceptionalTestCase.testMultipleResourcesInSingleStatementcs�t��t��d�_���fdd�}�jt|��j���j�j��j�jd��j�j	��j�j
��j�jd�dS)NcsQ��D�_�j���j�j��j���
�_WdQRXWdQRXdS)N)r1rVrZr\rir)rgrhrrrrJ�s

zPExceptionalTestCase.testNestedExceptionBeforeInnerStatement.<locals>.shouldThrow)r rir3r$r^r_r1rKrTrr	r
)rrJr)rgrhrr�'testNestedExceptionBeforeInnerStatement�s			
z;ExceptionalTestCase.testNestedExceptionBeforeInnerStatementcsxt��t�����fdd�}�jt|��j���j���j�j��j�j�dS)Ncsn��a�_��D�_�j���j���j�j��j�j�WdQRX�j�WdQRXdS)N)r1rirVrZr\r)rgrhrrrrJ�s

zOExceptionalTestCase.testNestedExceptionAfterInnerStatement.<locals>.shouldThrow)	r r3r$r^rXr_r1r[ri)rrJr)rgrhrr�&testNestedExceptionAfterInnerStatement�s		

z:ExceptionalTestCase.testNestedExceptionAfterInnerStatementc
sRtdd����fdd�}|jtd��|jt|�WdQRXdS)Ncss	dVdS)Nrrrrrr{�sz8ExceptionalTestCase.testRaisedStopIteration1.<locals>.cmc	s!���td��WdQRXdS)Nz	from with)�
StopIterationr)r{rrrJ�s
zAExceptionalTestCase.testRaisedStopIteration1.<locals>.shouldThrowr�)r�assertWarnsRegex�PendingDeprecationWarningr3r�)rrJr)r{r�testRaisedStopIteration1�sz,ExceptionalTestCase.testRaisedStopIteration1cs<Gdd�dt���fdd�}|jt|�dS)Nc@s(eZdZdd�Zdd�ZdS)z8ExceptionalTestCase.testRaisedStopIteration2.<locals>.cmcSsdS)Nr)rrrrr�szBExceptionalTestCase.testRaisedStopIteration2.<locals>.cm.__enter__cSsdS)Nr)rrrrrrrr�szAExceptionalTestCase.testRaisedStopIteration2.<locals>.cm.__exit__N)rrrrrrrrrr{�sr{c	s!���td��WdQRXdS)Nz	from with)r�r)r{rrrJ�s
zAExceptionalTestCase.testRaisedStopIteration2.<locals>.shouldThrow)r8r3r�)rrJr)r{r�testRaisedStopIteration2�sz,ExceptionalTestCase.testRaisedStopIteration2c
sRtdd����fdd�}|jtd��|jt|�WdQRXdS)Ncss	dVdS)Nrrrrrr{�sz8ExceptionalTestCase.testRaisedStopIteration3.<locals>.cmc
s'���ttg���WdQRXdS)N)�next�iterr)r{rrrJ�s
zAExceptionalTestCase.testRaisedStopIteration3.<locals>.shouldThrowr�)rr�r�r3r�)rrJr)r{r�testRaisedStopIteration3�sz,ExceptionalTestCase.testRaisedStopIteration3cs8tdd����fdd�}|jt|�dS)Ncss	dVdS)Nrrrrrr{�sz8ExceptionalTestCase.testRaisedGeneratorExit1.<locals>.cmc	s!���td��WdQRXdS)Nz	from with)�
GeneratorExitr)r{rrrJ�s
zAExceptionalTestCase.testRaisedGeneratorExit1.<locals>.shouldThrow)rr3r�)rrJr)r{r�testRaisedGeneratorExit1�sz,ExceptionalTestCase.testRaisedGeneratorExit1cs<Gdd�dt���fdd�}|jt|�dS)Nc@s(eZdZdd�Zdd�ZdS)z8ExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cmcSsdS)Nr)rrrrr�szBExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cm.__enter__cSsdS)Nr)rrrrrrrr�szAExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cm.__exit__N)rrrrrrrrrr{�sr{c	s!���td��WdQRXdS)Nz	from with)r�r)r{rrrJ�s
zAExceptionalTestCase.testRaisedGeneratorExit2.<locals>.shouldThrow)r8r3r�)rrJr)r{r�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)rr�r�r)r�rrsz9ExceptionalTestCase.testErrorsInBool.<locals>.cm.__init__cSsdS)N�r)rrrrrsz:ExceptionalTestCase.testErrorsInBool.<locals>.cm.__enter__cSs|jS)N)r�)r�a�b�crrrrsz9ExceptionalTestCase.testErrorsInBool.<locals>.cm.__exit__N)rrrrrrrrrrr{sr{c	s+�dd����jd�WdQRXdS)NcSsdS)NTrrrrr�<lambda>szJExceptionalTestCase.testErrorsInBool.<locals>.trueAsBool.<locals>.<lambda>zShould NOT see this)�failr)r{rrr�
trueAsBoolsz8ExceptionalTestCase.testErrorsInBool.<locals>.trueAsBoolc	s+�dd����jd�WdQRXdS)NcSsdS)NFrrrrrr�szKExceptionalTestCase.testErrorsInBool.<locals>.falseAsBool.<locals>.<lambda>zShould raise)r�r)r{rrr�falseAsBoolsz9ExceptionalTestCase.testErrorsInBool.<locals>.falseAsBoolc	s+�dd����jd�WdQRXdS)NcSsddS)Nr+rrrrrrr�szJExceptionalTestCase.testErrorsInBool.<locals>.failAsBool.<locals>.<lambda>zShould NOT see this)r�r)r{rrr�
failAsBoolsz8ExceptionalTestCase.testErrorsInBool.<locals>.failAsBool)r8r3�AssertionErrorr})rr�r�r�r)r{rr�testErrorsInBoolsz$ExceptionalTestCase.testErrorsInBoolN)rrrr|r~rjr�r�r�r�r�r�r�r�r�rrrrry_s

ryc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�NonLocalFlowControlTestCasec	CsQd}x4|d7}t��|d7}PWdQRX|d7}q	W|j|d�dS)Nrr+�
�d�)r rK)r�counterrrr�
testWithBreak#s


z)NonLocalFlowControlTestCase.testWithBreakc	Cs`d}xC|d7}|dkr Pt��|d7}w	WdQRX|d7}q	W|j|d�dS)Nrr+r,r�r��)r rK)rr�rrr�testWithContinue-s



z,NonLocalFlowControlTestCase.testWithContinuecCs#dd�}|j|�d�dS)Nc	SsDd}x7|d7}t��|d7}|SWdQRX|d7}q	WdS)Nrr+r�r�)r )r�rrrr1:s


z7NonLocalFlowControlTestCase.testWithReturn.<locals>.foor�)rK)rr1rrr�testWithReturn9sz*NonLocalFlowControlTestCase.testWithReturncCs5dd�}t|��}|j|ddg�dS)Nc	sst��dVdVWdQRXdS)Nr��
)r rrrr�genEs
z6NonLocalFlowControlTestCase.testWithYield.<locals>.genr�r�)�listrK)rr��xrrr�
testWithYieldDsz)NonLocalFlowControlTestCase.testWithYieldcCsud}y9|d7}t��|d7}t�WdQRX|d7}Wn"tk
rc|j|d�YnX|jd�dS)Nrr+r�r�r�zDidn't raise RuntimeError)r r$rKr�)rr�rrr�
testWithRaiseLs




z)NonLocalFlowControlTestCase.testWithRaiseN)rrrr�r�r�r�r�rrrrr�!s

r�c@s(eZdZdd�Zdd�ZdS)�AssignmentTargetTestCasec Cscddddgi}t��I|dd<|jt|j��dg�|j|ddjt�WdQRXt��Ut|j��dd<|jt|j��dg�|j|ddjt�WdQRXt��=|d<t|j��}|j�|j|ddg�WdQRXGdd�d�}|�}t��#|_|jt	|d�d�WdQRXdS)Nr+rr,c@seZdZdS)z;AssignmentTargetTestCase.testSingleComplexTarget.<locals>.CN)rrrrrrr�Chsr�r1T)
r rKr��keysr
r�values�sortr1�hasattr)r�targetsr�r��blahrrr�testSingleComplexTarget\s" "
	z0AssignmentTargetTestCase.testSingleComplexTargetc Cs�Gdd�d�}ddddgi}|��G\|dd<|dd<|dd<|j|ddddgi�WdQRX|��k\t|j��dd<t|j��dd<t|j��dd<|j|ddddgi�WdQRX|��>\|d<|d<|d<|j|ddddddi�WdQRXGdd�d�}|�}|��R\|_|_|_|j|jd�|j|jd�|j|jd�WdQRXdS)	Nc@s(eZdZdd�Zdd�ZdS)z>AssignmentTargetTestCase.testMultipleComplexTargets.<locals>.CcSsdS)Nr+r,r�)r+r,r�r)rrrrroszHAssignmentTargetTestCase.testMultipleComplexTargets.<locals>.C.__enter__cSsdS)Nr)r�t�v�tbrrrrpszGAssignmentTargetTestCase.testMultipleComplexTargets.<locals>.C.__exit__N)rrrrrrrrrr�nsr�r+rr,r�c@seZdZdS)z>AssignmentTargetTestCase.testMultipleComplexTargets.<locals>.BN)rrrrrrr�Bxsr�)rKr�r�ZoneZtwoZthree)rr�r�r�r�rrr�testMultipleComplexTargetsms-&Q&!)	z3AssignmentTargetTestCase.testMultipleComplexTargetsN)rrrr�r�rrrrr�Zsr�c@s(eZdZdd�Zdd�ZdS)�ExitSwallowsExceptionTestCasecCsVGdd�d�}y|��
ddWdQRXWntk
rQ|jd�YnXdS)Nc@s(eZdZdd�Zdd�ZdS)zSExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallowcSsdS)Nr)rrrrr�sz]ExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallow.__enter__cSsdS)NTr)rr�r�r�rrrr�sz\ExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallow.__exit__N)rrrrrrrrr�AfricanSwallow�sr�r+rz,ZeroDivisionError should have been swallowed)r}r�)rr�rrr�testExitTrueSwallowsException�s

z;ExitSwallowsExceptionTestCase.testExitTrueSwallowsExceptioncCsVGdd�d�}y|��
ddWdQRXWntk
rDYnX|jd�dS)Nc@s(eZdZdd�Zdd�ZdS)zZExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallowcSsdS)Nr)rrrrr�szdExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallow.__enter__cSsdS)NFr)rr�r�r�rrrr�szcExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallow.__exit__N)rrrrrrrrr�EuropeanSwallow�sr�r+rz)ZeroDivisionError should have been raised)r}r�)rr�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|}||_||_d|_d|_dS)NF)r�gobblerr	)rrr�rrrr�s			zNestedWith.Dummy.__init__cCsd|_|jS)NT)rr)rrrrr�s	zNestedWith.Dummy.__enter__cGs#d|_||_|jrdSdS)NT)r	r(r�)rr(rrrr�s			zNestedWith.Dummy.__exit__)rrrrrrrrrr�Dummy�sr�c@seZdZdd�ZdS)zNestedWith.InitRaisescCs
t��dS)N)r$)rrrrr�szNestedWith.InitRaises.__init__N)rrrrrrrr�
InitRaises�sr�c@s(eZdZdd�Zdd�ZdS)zNestedWith.EnterRaisescCs
t��dS)N)r$)rrrrr�sz NestedWith.EnterRaises.__enter__cGsdS)Nr)rr(rrrr�szNestedWith.EnterRaises.__exit__N)rrrrrrrrr�EnterRaises�sr�c@s(eZdZdd�Zdd�ZdS)zNestedWith.ExitRaisescCsdS)Nr)rrrrr�szNestedWith.ExitRaises.__enter__cGs
t��dS)N)r$)rr(rrrr�szNestedWith.ExitRaises.__exit__N)rrrrrrrrr�
ExitRaises�sr�cCsp|j��=}|j��'}|j|j�|j|j�WdQRXWdQRX|j|j�|j|j�dS)N)r�rSrr	)rr�r�rrr�testNoExceptions�s
zNestedWith.testNoExceptionscCs]y.|j��}|j��WdQRXWdQRXWnYnX|j|j�|j|j�dS)N)r�r�rSrr	)rr�rrr�testExceptionInExprList�sz"NestedWith.testExceptionInExprListcCs�y;|j��(}|j��|jd�WdQRXWdQRXWntk
rOYnX|jd�|j|j�|j|j�dS)Nzbody of bad with executedzRuntimeError not reraised)r�r�r�r$rSrr	)rr�rrr�testExceptionInEnter�s

zNestedWith.testExceptionInEntercCs�d}|jdd��!}|j��d}WdQRXWdQRX|j|j�|j|j�|j|�|j|jdd�dS)NFr�Tr)r�r�rSrr	ZassertNotEqualr()rZ
body_executedr�rrr�testExceptionInExit�s"
zNestedWith.testExceptionInExitcCs�|jdd��o\}}|jdd��M\}}|jd|�|jd|�|jd|�|jd|�WdQRXWdQRXdS)Nrr+r,r��)r+r,)r�r�)r�rK)rZa1Za2Zb1Zb2rrr�testEnterReturnsTuple�sz NestedWith.testEnterReturnsTupleN)
rrrr8r�r�r�r�r�r�r�r�r�rrrrr��s		r��__main__)�
__author__Z	__email__r'Zunittest�collectionsr�
contextlibrrrrr8rr r!r/ZTestCaser0rPr`rkryr�r�r�r�r�mainrrrr�<module>s.
$O/5	A�9&L