HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_with.cpython-37.pyc
B

��gg�@sHdZdZdZddlZddlZddlmZddlmZm	Z	Gdd�de�Z
d	d
�ZGdd�de�Z
ed
d��ZGdd�de�ZGdd�de�ZGdd�dej�ZGdd�de�ZGdd�deje�ZGdd�deje�ZGdd�deej�ZGdd�dej�ZGdd �d ej�ZGd!d"�d"ej�ZGd#d$�d$ej�Zed%k�rDe��dS)&z7Unit tests for the with statement specified in PEP 343.z
Mike Blandzmbland at acm dot org�N)�deque)�_GeneratorContextManager�contextmanagercs,eZdZ�fdd�Zdd�Zdd�Z�ZS)�MockContextManagercs"t�j|�d|_d|_d|_dS)NF)�super�__init__�enter_called�exit_called�	exit_args)�self�args)�	__class__��*/usr/local/lib/python3.7/test/test_with.pyrszMockContextManager.__init__cCsd|_t�|�S)NT)rr�	__enter__)rrrrrszMockContextManager.__enter__cCs"d|_|||f|_t�||||�S)NT)r	r
r�__exit__)r�type�value�	tracebackrrrrszMockContextManager.__exit__)�__name__�
__module__�__qualname__rrr�
__classcell__rr)r
rr
srcs�fdd�}|S)Ncst�||�S)N)r)r�kwds)�funcrr�helper sz#mock_contextmanager.<locals>.helperr)rrr)rr�mock_contextmanagersrc@seZdZdd�ZdS)�MockResourcecCsd|_d|_dS)NF)�yielded�stopped)rrrrr&szMockResource.__init__N)rrrrrrrrr%srccs$t�}zd|_|VWdd|_XdS)NT)rrr)�mockrrr�mock_contextmanager_generator+s

r!c@s$eZdZdd�Zdd�Zdd�ZdS)�NestedcGs||_d|_dS)N)�managers�entered)rr#rrrr7szNested.__init__cCsn|jdk	rtd��t�|_g}y.x(|jD]}|�|���|j�|�q(WWn|jt�	��sd�YnX|S)NzContext is not reentrant)
r$�RuntimeErrorrr#�appendr�
appendleftr�sys�exc_info)r�vars�mgrrrrr;s
zNested.__enter__cGsh|}x6|jD],}y|j|�r d}Wqt��}YqXqWd|_||k	rd|d|d��|d��dS)N)NNNr��)r$rr(r)�with_traceback)rr)Zexr+rrrrIs
zNested.__exit__N)rrrrrrrrrrr"5sr"c@s$eZdZdd�Zdd�Zdd�ZdS)�
MockNestedcGs&tj|f|��d|_d|_d|_dS)NF)r"rrr	r
)rr#rrrrZszMockNested.__init__cCsd|_t�|�S)NT)rr"r)rrrrr`szMockNested.__enter__cGsd|_||_tj|f|��S)NT)r	r
r"r)rr)rrrrdszMockNested.__exit__N)rrrrrrrrrrr/Ysr/c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�FailureTestCasecCsdd�}|�t|�dS)Nc	Sst�WdQRXdS)N)�foorrrr�fooNotDeclaredlsz5FailureTestCase.testNameError.<locals>.fooNotDeclared)�assertRaises�	NameError)rr2rrr�
testNameErrorkszFailureTestCase.testNameErrorcs.Gdd�dt���fdd�}|�td|�dS)Nc@seZdZdd�ZdS)z<FailureTestCase.testEnterAttributeError1.<locals>.LacksEntercSsdS)Nr)rrrrrrrrrszEFailureTestCase.testEnterAttributeError1.<locals>.LacksEnter.__exit__N)rrrrrrrr�
LacksEnterqsr6c	s��}|�WdQRXdS)Nr)r1)r6rr�
fooLacksEnterusz?FailureTestCase.testEnterAttributeError1.<locals>.fooLacksEnterr)�object�assertRaisesRegex�AttributeError)rr7r)r6r�testEnterAttributeError1psz(FailureTestCase.testEnterAttributeError1cs.Gdd�dt���fdd�}|�td|�dS)Nc@seZdZdS)zCFailureTestCase.testEnterAttributeError2.<locals>.LacksEnterAndExitN)rrrrrrr�LacksEnterAndExit{sr<c	s��}|�WdQRXdS)Nr)r1)r<rr�fooLacksEnterAndExit~szFFailureTestCase.testEnterAttributeError2.<locals>.fooLacksEnterAndExitr)r8r9r:)rr=r)r<r�testEnterAttributeError2zsz(FailureTestCase.testEnterAttributeError2cs.Gdd�dt���fdd�}|�td|�dS)Nc@seZdZdd�ZdS)z9FailureTestCase.testExitAttributeError.<locals>.LacksExitcSsdS)Nr)rrrrr�szCFailureTestCase.testExitAttributeError.<locals>.LacksExit.__enter__N)rrrrrrrr�	LacksExit�sr?c	s��}|�WdQRXdS)Nr)r1)r?rr�fooLacksExit�sz<FailureTestCase.testExitAttributeError.<locals>.fooLacksExitr)r8r9r:)rr@r)r?r�testExitAttributeError�sz&FailureTestCase.testExitAttributeErrorcCsdd�}|�t||�dS)NcSst|dd�dS)N�Zsingle)�compile)�srrr�shouldRaiseSyntaxError�szGFailureTestCase.assertRaisesSyntaxError.<locals>.shouldRaiseSyntaxError)r3�SyntaxError)rZcodestrrErrr�assertRaisesSyntaxError�sz'FailureTestCase.assertRaisesSyntaxErrorcCs|�d�|�d�dS)Nzwith mock as None:
  passzwith mock as (None):
  pass)rG)rrrr�testAssignmentToNoneError�s
z)FailureTestCase.testAssignmentToNoneErrorcCs|�d�|�d�dS)Nzwith mock as None,:
  passzwith mock as (None,):
  pass)rG)rrrr�,testAssignmentToTupleOnlyContainingNoneError�s
z<FailureTestCase.testAssignmentToTupleOnlyContainingNoneErrorcCs|�d�dS)Nz%with mock as (foo, None, bar):
  pass)rG)rrrr�(testAssignmentToTupleContainingNoneError�sz8FailureTestCase.testAssignmentToTupleContainingNoneErrorcs<Gdd�dt����fdd�}��t|����jd�dS)Nc@seZdZdd�Zdd�ZdS)z4FailureTestCase.testEnterThrows.<locals>.EnterThrowscSstd��dS)NzEnter threw)r%)rrrrr�sz>FailureTestCase.testEnterThrows.<locals>.EnterThrows.__enter__cWsdS)Nr)rrrrrr�sz=FailureTestCase.testEnterThrows.<locals>.EnterThrows.__exit__N)rrrrrrrrr�EnterThrows�srKc	s"��}d�_|��_WdQRXdS)N)r1)Zct)rKrrr�shouldThrow�sz4FailureTestCase.testEnterThrows.<locals>.shouldThrow)r8r3r%�assertEqualr1)rrLr)rKrr�testEnterThrows�szFailureTestCase.testEnterThrowscs,Gdd�dt���fdd�}|�t|�dS)Nc@seZdZdd�Zdd�ZdS)z2FailureTestCase.testExitThrows.<locals>.ExitThrowscSsdS)Nr)rrrrr�sz<FailureTestCase.testExitThrows.<locals>.ExitThrows.__enter__cWstd��dS)N�*)r%)rrrrrr�sz;FailureTestCase.testExitThrows.<locals>.ExitThrows.__exit__N)rrrrrrrrr�
ExitThrows�srPc	s���WdQRXdS)Nrr)rPrrrL�sz3FailureTestCase.testExitThrows.<locals>.shouldThrow)r8r3r%)rrLr)rPr�testExitThrows�szFailureTestCase.testExitThrowsN)
rrrr5r;r>rArGrHrIrJrNrQrrrrr0js
	
r0c@sVeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
dd�ZdS)�ContextmanagerAssertionMixincCstd�|_dS)Nztest exception)r%�TEST_EXCEPTION)rrrr�setUp�sz"ContextmanagerAssertionMixin.setUpcCs*|�|j�|�|j�|�|jd�dS)N)�
assertTruer�assertFalser	rMr
)r�mock_managerrrr�assertInWithManagerInvariants�sz:ContextmanagerAssertionMixin.assertInWithManagerInvariantscCs*|�|j�|�|j�|�|j|�dS)N)rUrr	rMr
)rrWr
rrr� assertAfterWithManagerInvariants�sz=ContextmanagerAssertionMixin.assertAfterWithManagerInvariantscCs|�|d�dS)N)NNN)rY)rrWrrr�'assertAfterWithManagerInvariantsNoError�szDContextmanagerAssertionMixin.assertAfterWithManagerInvariantsNoErrorcCs|�|j�|�|j�dS)N)rUrrVr)r�mock_generatorrrr�assertInWithGeneratorInvariants�sz<ContextmanagerAssertionMixin.assertInWithGeneratorInvariantscCs|�|j�|�|j�dS)N)rUrr)rr[rrr�)assertAfterWithGeneratorInvariantsNoError�szFContextmanagerAssertionMixin.assertAfterWithGeneratorInvariantsNoErrorcCs
|j�dS)N)rS)rrrr�raiseTestException�sz/ContextmanagerAssertionMixin.raiseTestExceptionNcCsx|�|j�|�|j�|dkr>|�|jd|j�t|j�}|�|jd|�|�|jd|�|�|jdd�dS)Nr,rr-)	rUrr	rMr
rSrZassertIsInstanceZassertIsNot)rrW�exc_typerrr�)assertAfterWithManagerInvariantsWithError�s
zFContextmanagerAssertionMixin.assertAfterWithManagerInvariantsWithErrorcCs|�|j�|�|j�dS)N)rUrr)rr[rrr�+assertAfterWithGeneratorInvariantsWithError�szHContextmanagerAssertionMixin.assertAfterWithGeneratorInvariantsWithError)N)rrrrTrXrYrZr\r]r^r`rarrrrrR�s
rRc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�NonexceptionalTestCasec	Cst��WdQRXdS)N)r!)rrrr�testInlineGeneratorSyntax�sz0NonexceptionalTestCase.testInlineGeneratorSyntaxc	Cs$t�}|�WdQRX|�|�dS)N)r!rZ)rr rrr�testUnboundGenerator�s
z+NonexceptionalTestCase.testUnboundGeneratorc	Cs*t��}|�|�WdQRX|�|�dS)N)r!r\r])rr1rrr�testInlineGeneratorBoundSyntax�sz5NonexceptionalTestCase.testInlineGeneratorBoundSyntaxc	Cs.d}t��}|�|�WdQRX|�|�dS)N)r!r\r])rr1rrr�*testInlineGeneratorBoundToExistingVariable�szANonexceptionalTestCase.testInlineGeneratorBoundToExistingVariablec	Cs0t��|_|�|j�WdQRX|�|j�dS)N)r!r1r\r])rrrr�(testInlineGeneratorBoundToDottedVariables
z?NonexceptionalTestCase.testInlineGeneratorBoundToDottedVariablec	CsBt�}|�}|�|�|�|�WdQRX|�|�|�|�dS)N)r!r\rXr]rZ)rr r1rrr�testBoundGenerators

z)NonexceptionalTestCase.testBoundGeneratorc
Cs�t�}|�l}t�}|�.}|�|�|�|�|�|�|�|�WdQRX|�|�|�|�|�|�|�|�WdQRX|�|�|�|�dS)N)r!rXr\rZr])r�mock_ar1�mock_b�barrrr�testNestedSingleStatementss






z1NonexceptionalTestCase.testNestedSingleStatementsN)
rrrrcrdrerfrgrhrlrrrrrb�srbc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�NestedNonexceptionalTestCasec	Cstt���WdQRXdS)N)r"r!)rrrr�"testSingleArgInlineGeneratorSyntax#sz?NestedNonexceptionalTestCase.testSingleArgInlineGeneratorSyntaxc	Cs2t�}t|��}|�|�WdQRX|�|�dS)N)r!r"rXrZ)r�mr1rrr�testSingleArgBoundToNonTuple's
z9NestedNonexceptionalTestCase.testSingleArgBoundToNonTuplec	Cs2t�}t|��}|�|�WdQRX|�|�dS)N)r!r"rXrZ)rror1rrr�2testSingleArgBoundToSingleElementParenthesizedList/s
zONestedNonexceptionalTestCase.testSingleArgBoundToSingleElementParenthesizedListcCsdd�}|�t|�dS)Nc	Sstt���
\}}WdQRXdS)N)r"r!)r1rkrrr�shouldThrowValueError8sziNestedNonexceptionalTestCase.testSingleArgBoundToMultipleElementTupleError.<locals>.shouldThrowValueError)r3�
ValueError)rrrrrr�-testSingleArgBoundToMultipleElementTupleError7szJNestedNonexceptionalTestCase.testSingleArgBoundToMultipleElementTupleErrorc	CsJt�}t|�}|�|�|�|�|�WdQRX|�|�|�|�dS)N)r!r/rXrZ)rr�mock_nestedrrr�testSingleArgUnbound=s

z1NestedNonexceptionalTestCase.testSingleArgUnboundc	Cs�t�}t�}t�}t|||�}|�.|�|�|�|�|�|�|�|�WdQRX|�|�|�|�|�|�|�|�dS)N)r!r/rXrZ)rro�n�orurrr�testMultipleArgUnboundFs





z3NestedNonexceptionalTestCase.testMultipleArgUnboundc	Cs|tt�t�t��}|�4\}}}|�|�|�|�|�|�|�|�WdQRX|�|�|�|�|�|�|�|�dS)N)r/r!r\rXr]rZ)rrurorwrxrrr�testMultipleArgBoundUs





z1NestedNonexceptionalTestCase.testMultipleArgBoundN)
rrrrnrprqrtrvryrzrrrrrm!s	rmc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�ExceptionalTestCasecs:t����fdd�}��t|��������j�dS)Nc	s4��&�_�������j����WdQRXdS)N)�resourcerXr\r^r)�cmrrrrLfs
z;ExceptionalTestCase.testSingleResource.<locals>.shouldThrow)r!r3r%r`rar|)rrLr)r}rr�testSingleResourceds

z&ExceptionalTestCase.testSingleResourcecs0t����fdd�}��t|����t�dS)Nc	s���_ddWdQRXdS)Nr,r)r|r)r}rrrrLqsz@ExceptionalTestCase.testExceptionNormalized.<locals>.shouldThrow)r!r3�ZeroDivisionErrorr`)rrLr)r}rr�testExceptionNormalizedosz+ExceptionalTestCase.testExceptionNormalizedcsXt��t�����fdd�}��t|������������j����j�dS)Nc
s\��N�_��<�_�����������j����j����WdQRXWdQRXdS)N)r1rkrXr\r^r)rirjrrrrL|s

zCExceptionalTestCase.testNestedSingleStatements.<locals>.shouldThrow)r!r3r%r`rar1rk)rrLr)rirjrrrlys

z.ExceptionalTestCase.testNestedSingleStatementscsnt��t��t��������fdd�}��t|����������������j����j�dS)Nc	sZ��L\�_�_���������������j����j����WdQRXdS)N)�
resource_a�
resource_brXr\r^r)�cm_a�cm_brurrrrL�s


zOExceptionalTestCase.testMultipleResourcesInSingleStatement.<locals>.shouldThrow)r!r/r3r%r`rar�r�)rrLr)r�r�rurr�&testMultipleResourcesInSingleStatement�s



z:ExceptionalTestCase.testMultipleResourcesInSingleStatementcs|t��t��d�_���fdd�}��t|��������j����jd����j	����j
����jd�dS)Nc
sF��8�_�������j�������_WdQRXWdQRXdS)N)r1rXr\r^rkr)rirjrrrrL�s
zPExceptionalTestCase.testNestedExceptionBeforeInnerStatement.<locals>.shouldThrow)r!rkr3r%r`rar1rMrVrr	r
)rrLr)rirjrr�'testNestedExceptionBeforeInnerStatement�s
z;ExceptionalTestCase.testNestedExceptionBeforeInnerStatementcsXt��t�����fdd�}��t|������������j����j�dS)Nc
s\��N�_��4�_�����������j����j�WdQRX���WdQRXdS)N)r1rkrXr\r^r)rirjrrrrL�s

zOExceptionalTestCase.testNestedExceptionAfterInnerStatement.<locals>.shouldThrow)	r!r3r%r`rZrar1r]rk)rrLr)rirjrr�&testNestedExceptionAfterInnerStatement�s

z:ExceptionalTestCase.testNestedExceptionAfterInnerStatementc	s:tdd����fdd�}|�td��|�WdQRXdS)Ncss
dVdS)Nrrrrrr}�sz8ExceptionalTestCase.testRaisedStopIteration1.<locals>.cmc	s���td��WdQRXdS)Nz	from with)�
StopIterationr)r}rrrL�szAExceptionalTestCase.testRaisedStopIteration1.<locals>.shouldThrowz	from with)rr9r�)rrLr)r}r�testRaisedStopIteration1�sz,ExceptionalTestCase.testRaisedStopIteration1c	s>Gdd�dt���fdd�}|�td��|�WdQRXdS)Nc@seZdZdd�Zdd�ZdS)z8ExceptionalTestCase.testRaisedStopIteration2.<locals>.cmcSsdS)Nr)rrrrr�szBExceptionalTestCase.testRaisedStopIteration2.<locals>.cm.__enter__cSsdS)Nr)rrrrrrrr�szAExceptionalTestCase.testRaisedStopIteration2.<locals>.cm.__exit__N)rrrrrrrrrr}�sr}c	s���td��WdQRXdS)Nz	from with)r�r)r}rrrL�szAExceptionalTestCase.testRaisedStopIteration2.<locals>.shouldThrowz	from with)r8r9r�)rrLr)r}r�testRaisedStopIteration2�sz,ExceptionalTestCase.testRaisedStopIteration2c	s8tdd����fdd�}|�t��|�WdQRXdS)Ncss
dVdS)Nrrrrrr}�sz8ExceptionalTestCase.testRaisedStopIteration3.<locals>.cmc	s"���ttg���WdQRXdS)N)�next�iterr)r}rrrL�szAExceptionalTestCase.testRaisedStopIteration3.<locals>.shouldThrow)rr3r�)rrLr)r}r�testRaisedStopIteration3�sz,ExceptionalTestCase.testRaisedStopIteration3cs(tdd����fdd�}|�t|�dS)Ncss
dVdS)Nrrrrrr}�sz8ExceptionalTestCase.testRaisedGeneratorExit1.<locals>.cmc	s���td��WdQRXdS)Nz	from with)�
GeneratorExitr)r}rrrL�szAExceptionalTestCase.testRaisedGeneratorExit1.<locals>.shouldThrow)rr3r�)rrLr)r}r�testRaisedGeneratorExit1�sz,ExceptionalTestCase.testRaisedGeneratorExit1cs,Gdd�dt���fdd�}|�t|�dS)Nc@seZdZdd�Zdd�ZdS)z8ExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cmcSsdS)Nr)rrrrr�szBExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cm.__enter__cSsdS)Nr)rrrrrrrr�szAExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cm.__exit__N)rrrrrrrrrr}�sr}c	s���td��WdQRXdS)Nz	from with)r�r)r}rrrLszAExceptionalTestCase.testRaisedGeneratorExit2.<locals>.shouldThrow)r8r3r�)rrLr)r}r�testRaisedGeneratorExit2�sz,ExceptionalTestCase.testRaisedGeneratorExit2cs\Gdd�dt����fdd�}|���fdd�}��t|���fdd�}��t|�dS)	Nc@s$eZdZdd�Zdd�Zdd�ZdS)z0ExceptionalTestCase.testErrorsInBool.<locals>.cmcsG�fdd�d�}|�|_dS)NcseZdZ�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�Bool
sr�)�exit_result)rr�r�r)r�rrsz9ExceptionalTestCase.testErrorsInBool.<locals>.cm.__init__cSsdS)N�r)rrrrrsz:ExceptionalTestCase.testErrorsInBool.<locals>.cm.__enter__cSs|jS)N)r�)r�a�b�crrrrsz9ExceptionalTestCase.testErrorsInBool.<locals>.cm.__exit__N)rrrrrrrrrrr}sr}c	s&�dd�����d�WdQRXdS)NcSsdS)NTrrrrr�<lambda>�zJExceptionalTestCase.testErrorsInBool.<locals>.trueAsBool.<locals>.<lambda>zShould NOT see this)�failr)r}rrr�
trueAsBoolsz8ExceptionalTestCase.testErrorsInBool.<locals>.trueAsBoolc	s&�dd�����d�WdQRXdS)NcSsdS)NFrrrrrr�r�zKExceptionalTestCase.testErrorsInBool.<locals>.falseAsBool.<locals>.<lambda>zShould raise)r�r)r}rrr�falseAsBoolsz9ExceptionalTestCase.testErrorsInBool.<locals>.falseAsBoolc	s&�dd�����d�WdQRXdS)NcSsddS)Nr,rrrrrrr�!r�zJExceptionalTestCase.testErrorsInBool.<locals>.failAsBool.<locals>.<lambda>zShould NOT see this)r�r)r}rrr�
failAsBool sz8ExceptionalTestCase.testErrorsInBool.<locals>.failAsBool)r8r3�AssertionErrorr)rr�r�r�r)r}rr�testErrorsInBoolsz$ExceptionalTestCase.testErrorsInBoolN)rrrr~r�rlr�r�r�r�r�r�r�r�r�rrrrr{cs

r{c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�NonLocalFlowControlTestCasec	CsFd}x0|d7}t��|d7}PWdQRX|d7}qW|�|d�dS)Nrr,�
�d�)r!rM)r�counterrrr�
testWithBreak(sz)NonLocalFlowControlTestCase.testWithBreakc	CsPd}x:|d7}|dkrPt��|d7}wWdQRX|d7}qW|�|d�dS)Nrr,r-r�r��)r!rM)rr�rrr�testWithContinue2sz,NonLocalFlowControlTestCase.testWithContinuecCsdd�}|�|�d�dS)Nc	Ss8d}x.|d7}t��|d7}|SQRX|d7}qWdS)Nrr,r�r�)r!)r�rrrr1?s
z7NonLocalFlowControlTestCase.testWithReturn.<locals>.foor�)rM)rr1rrr�testWithReturn>sz*NonLocalFlowControlTestCase.testWithReturncCs&dd�}t|��}|�|ddg�dS)Nc	ss"t��dVdVWdQRXdS)Nr��
)r!rrrr�genJsz6NonLocalFlowControlTestCase.testWithYield.<locals>.genr�r�)�listrM)rr��xrrr�
testWithYieldIs
z)NonLocalFlowControlTestCase.testWithYieldc	Csfd}y2|d7}t��|d7}t�WdQRX|d7}Wn tk
rV|�|d�YnX|�d�dS)Nrr,r�r�r�zDidn't raise RuntimeError)r!r%rMr�)rr�rrr�
testWithRaiseQsz)NonLocalFlowControlTestCase.testWithRaiseN)rrrr�r�r�r�r�rrrrr�&s

r�c@seZdZdd�Zdd�ZdS)�AssignmentTargetTestCasec	Csddddgi}t��:|dd<|�t|���dg�|�|ddjt�WdQRXt��Bt|���dd<|�t|���dg�|�|ddjt�WdQRXt��.|d<t|���}|��|�|ddg�WdQRXGdd�d�}|�}t��|_|�t	|d�d�WdQRXdS)Nr,rr-c@seZdZdS)z;AssignmentTargetTestCase.testSingleComplexTarget.<locals>.CN)rrrrrrr�Cmsr�r1T)
r!rMr��keysr
r�values�sortr1�hasattr)r�targetsr�r��blahrrr�testSingleComplexTargetas  
z0AssignmentTargetTestCase.testSingleComplexTargetc	CsXGdd�d�}ddddgi}|��:\|dd<|dd<|dd<|�|ddddgi�WdQRX|��R\t|���dd<t|���dd<t|���dd<|�|ddddgi�WdQRX|��,\|d<|d<|d<|�|dddd��WdQRXGdd	�d	�}|�}|��<\|_|_|_|�|jd�|�|jd�|�|jd�WdQRXdS)
Nc@seZdZdd�Zdd�ZdS)z>AssignmentTargetTestCase.testMultipleComplexTargets.<locals>.CcSsdS)N)r,r-r�r)rrrrrtr�zHAssignmentTargetTestCase.testMultipleComplexTargets.<locals>.C.__enter__cSsdS)Nr)r�t�v�tbrrrrur�zGAssignmentTargetTestCase.testMultipleComplexTargets.<locals>.C.__exit__N)rrrrrrrrrr�ssr�r,rr-r�)r,r-r�c@seZdZdS)z>AssignmentTargetTestCase.testMultipleComplexTargets.<locals>.BN)rrrrrrr�B}sr�)rMr�r�ZoneZtwoZthree)rr�r�r�r�rrr�testMultipleComplexTargetsrs& > z3AssignmentTargetTestCase.testMultipleComplexTargetsN)rrrr�r�rrrrr�_sr�c@seZdZdd�Zdd�ZdS)�ExitSwallowsExceptionTestCasec	CsPGdd�d�}y|��ddWdQRXWntk
rJ|�d�YnXdS)Nc@seZdZdd�Zdd�ZdS)zSExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallowcSsdS)Nr)rrrrr�r�z]ExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallow.__enter__cSsdS)NTr)rr�r�r�rrrr�r�z\ExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallow.__exit__N)rrrrrrrrr�AfricanSwallow�sr�r,rz,ZeroDivisionError should have been swallowed)rr�)rr�rrr�testExitTrueSwallowsException�sz;ExitSwallowsExceptionTestCase.testExitTrueSwallowsExceptionc	CsPGdd�d�}y|��ddWdQRXWntk
r@YnX|�d�dS)Nc@seZdZdd�Zdd�ZdS)zZExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallowcSsdS)Nr)rrrrr�r�zdExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallow.__enter__cSsdS)NFr)rr�r�r�rrrr�r�zcExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallow.__exit__N)rrrrrrrrr�EuropeanSwallow�sr�r,rz)ZeroDivisionError should have been raised)rr�)rr�rrr�#testExitFalseDoesntSwallowException�szAExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowExceptionN)rrrr�r�rrrrr��s
r�c@steZdZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)�
NestedWithc@s&eZdZd	dd�Zdd�Zdd�ZdS)
zNestedWith.DummyNFcCs(|dkr|}||_||_d|_d|_dS)NF)r�gobblerr	)rrr�rrrr�szNestedWith.Dummy.__init__cCsd|_|jS)NT)rr)rrrrr�szNestedWith.Dummy.__enter__cGsd|_||_|jrdSdS)NT)r	r)r�)rr)rrrr�szNestedWith.Dummy.__exit__)NF)rrrrrrrrrr�Dummy�s
r�c@seZdZdd�ZdS)zNestedWith.InitRaisescCs
t��dS)N)r%)rrrrr�r�zNestedWith.InitRaises.__init__N)rrrrrrrr�
InitRaises�sr�c@seZdZdd�Zdd�ZdS)zNestedWith.EnterRaisescCs
t��dS)N)r%)rrrrr�r�z NestedWith.EnterRaises.__enter__cGsdS)Nr)rr)rrrr�r�zNestedWith.EnterRaises.__exit__N)rrrrrrrrr�EnterRaises�sr�c@seZdZdd�Zdd�ZdS)zNestedWith.ExitRaisescCsdS)Nr)rrrrr�r�zNestedWith.ExitRaises.__enter__cGs
t��dS)N)r%)rr)rrrr�r�zNestedWith.ExitRaises.__exit__N)rrrrrrrrr�
ExitRaises�sr�c
Cs\|���2}|���}|�|j�|�|j�WdQRXWdQRX|�|j�|�|j�dS)N)r�rUrr	)rr�r�rrr�testNoExceptions�s
 zNestedWith.testNoExceptionsc
CsVy,|���}|���WdQRXWdQRXWnYnX|�|j�|�|j�dS)N)r�r�rUrr	)rr�rrr�testExceptionInExprList�sz"NestedWith.testExceptionInExprListc
Csry6|���$}|���|�d�WdQRXWdQRXWntk
rJYnX|�d�|�|j�|�|j�dS)Nzbody of bad with executedzRuntimeError not reraised)r�r�r�r%rUrr	)rr�rrr�testExceptionInEnter�s"
zNestedWith.testExceptionInEnterc
Csld}|jdd��}|���
d}WdQRXWdQRX|�|j�|�|j�|�|�|�|jdd�dS)NFT)r�r)r�r�rUrr	ZassertNotEqualr))rZ
body_executedr�rrr�testExceptionInExit�s
zNestedWith.testExceptionInExitc
Csl|jdd��V\}}|jdd��:\}}|�d|�|�d|�|�d|�|�d|�WdQRXWdQRXdS)N)r,r-)r)r��r,r-r�r�)r�rM)rZa1Za2Zb1Zb2rrr�testEnterReturnsTuple�sz NestedWith.testEnterReturnsTupleN)
rrrr8r�r�r�r�r�r�r�r�r�rrrrr��s		r��__main__)�__doc__�
__author__Z	__email__r(Zunittest�collectionsr�
contextlibrrrrr8rr!r"r/ZTestCaser0rRrbrmr{r�r�r�r�r�mainrrrr�<module>s2
$S/5AD9&L