Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.14.247.255
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_with.cpython-310.pyc
o

ab�g�@sNdZdZdZddlZddlZddlmZddlmZm	Z	m
Z
Gdd�de�Zd	d
�ZGdd�de
�Zed
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%kr�e��dSdS)&z7Unit tests for the with statement specified in PEP 343.z
Mike Blandzmbland at acm dot org�N)�deque)�_GeneratorContextManager�contextmanager�nullcontextcs,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__��7/usr/local/python-3.10/lib/python3.10/test/test_with.pyr	s
zMockContextManager.__init__cC�d|_t�|�S�NT)r
r�	__enter__�rrrrr�
zMockContextManager.__enter__cCs"d|_|||f|_t�||||�Sr)rrr�__exit__�r�type�value�	tracebackrrrrs
�zMockContextManager.__exit__)�__name__�
__module__�__qualname__r	rr�
__classcell__rrrrr
srcs�fdd�}|S)Ncst�||�S�N)r)r�kwds��funcrr�helper sz#mock_contextmanager.<locals>.helperr)r%r&rr$r�mock_contextmanagersr'c@�eZdZdd�ZdS)�MockResourcecCsd|_d|_dSr)�yielded�stoppedrrrrr	&rzMockResource.__init__N�rrr r	rrrrr)%�r)ccs*�t�}zd|_|VWd|_dSd|_wr)r)r*r+)�mockrrr�mock_contextmanager_generator+s�r/c@�$eZdZdd�Zdd�Zdd�ZdS)�NestedcGs||_d|_dSr")�managers�entered�rr2rrrr	7rzNested.__init__cCsh|jdur	td��t�|_g}z|jD]}|�|���|j�|�qW|S|jt�	��s1�Y|S)NzContext is not reentrant)
r3�RuntimeErrorrr2�appendr�
appendleftr�sys�exc_info)r�vars�mgrrrrr;s

���zNested.__enter__cGs`|}|jD]}z	|j|�rd}Wqt��}Yqd|_||ur.|d|d��|d��dS)N�NNNr��)r3rr8r9�with_traceback)rr9�exr;rrrrIs

��zNested.__exit__N�rrr r	rrrrrrr15sr1c@r0)�
MockNestedcGs(tj|g|�R�d|_d|_d|_dSr)r1r	r
rrr4rrrr	Zs
zMockNested.__init__cCrr)r
r1rrrrrr`rzMockNested.__enter__cGsd|_||_tj|g|�R�Sr)rrr1r�rr9rrrrdszMockNested.__exit__NrArrrrrBYsrBc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�FailureTestCasecC�dd�}|�t|�dS)NcSs*t�	Wd�dS1swYdSr"��foorrrr�fooNotDeclaredls*z5FailureTestCase.testNameError.<locals>.fooNotDeclared)�assertRaises�	NameError)rrHrrr�
testNameErrorkszFailureTestCase.testNameErrorc�.Gdd�dt���fdd�}|�td|�dS)Nc@r()z<FailureTestCase.testEnterAttributeError1.<locals>.LacksEntercS�dSr"rrrrrrr�zEFailureTestCase.testEnterAttributeError1.<locals>.LacksEnter.__exit__N)rrr rrrrr�
LacksEnterqr-rOc�0��}|�	Wd�dS1swYdSr"rrF�rOrr�
fooLacksEnteru�*z?FailureTestCase.testEnterAttributeError1.<locals>.fooLacksEnterr��object�assertRaisesRegex�AttributeError)rrRrrQr�testEnterAttributeError1p�z(FailureTestCase.testEnterAttributeError1crL)Nc@�eZdZdS)zCFailureTestCase.testEnterAttributeError2.<locals>.LacksEnterAndExitN�rrr rrrr�LacksEnterAndExit{sr\crPr"rrF�r\rr�fooLacksEnterAndExit~rSzFFailureTestCase.testEnterAttributeError2.<locals>.fooLacksEnterAndExitrrT)rr^rr]r�testEnterAttributeError2zsz(FailureTestCase.testEnterAttributeError2crL)Nc@r()z9FailureTestCase.testExitAttributeError.<locals>.LacksExitcSrMr"rrrrrr�rNzCFailureTestCase.testExitAttributeError.<locals>.LacksExit.__enter__N)rrr rrrrr�	LacksExit�r-r`crPr"rrF�r`rr�fooLacksExit�rSz<FailureTestCase.testExitAttributeError.<locals>.fooLacksExitrrT)rrbrrar�testExitAttributeError�rYz&FailureTestCase.testExitAttributeErrorcCsdd�}|�t||�dS)NcSst|dd�dS)N�Zsingle)�compile)�srrr�shouldRaiseSyntaxError�szGFailureTestCase.assertRaisesSyntaxError.<locals>.shouldRaiseSyntaxError)rI�SyntaxError)rZcodestrrgrrr�assertRaisesSyntaxError�sz'FailureTestCase.assertRaisesSyntaxErrorcC�|�d�|�d�dS)Nzwith mock as None:
  passzwith mock as (None):
  pass�rirrrr�testAssignmentToNoneError��
�z)FailureTestCase.testAssignmentToNoneErrorcCrj)Nzwith mock as None,:
  passzwith mock as (None,):
  passrkrrrr�,testAssignmentToTupleOnlyContainingNoneError�rmz<FailureTestCase.testAssignmentToTupleOnlyContainingNoneErrorcCs|�d�dS)Nz%with mock as (foo, None, bar):
  passrkrrrr�(testAssignmentToTupleContainingNoneError�s�z8FailureTestCase.testAssignmentToTupleContainingNoneErrorcs<Gdd�dt����fdd�}��t|����jd�dS)Nc@�eZdZdd�Zdd�ZdS)z4FailureTestCase.testEnterThrows.<locals>.EnterThrowscS�td��)NzEnter threw�r5rrrrr��z>FailureTestCase.testEnterThrows.<locals>.EnterThrows.__enter__cWrMr"rr
rrrr�rNz=FailureTestCase.testEnterThrows.<locals>.EnterThrows.__exit__N�rrr rrrrrr�EnterThrows��rucs8��}d�_|�
�_Wd�dS1swYdSr"rF)�ct�rurrr�shouldThrow�s
"�z4FailureTestCase.testEnterThrows.<locals>.shouldThrow)rUrIr5�assertEqualrG�rryrrxr�testEnterThrows�szFailureTestCase.testEnterThrowsc�,Gdd�dt���fdd�}|�t|�dS)Nc@rp)z2FailureTestCase.testExitThrows.<locals>.ExitThrowscSrMr"rrrrrr�rNz<FailureTestCase.testExitThrows.<locals>.ExitThrows.__enter__cWrq)N�*rrr
rrrr�rsz;FailureTestCase.testExitThrows.<locals>.ExitThrows.__exit__Nrtrrrr�
ExitThrows�rvrcs,���	Wd�dS1swYdSr"rr�rrrry��"�z3FailureTestCase.testExitThrows.<locals>.shouldThrow)rUrIr5r{rr�r�testExitThrows�szFailureTestCase.testExitThrowsN)
rrr rKrXr_rcrirlrnror|r�rrrrrDjs
	
rDc@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z		ddd�Z
dd�ZdS)�ContextmanagerAssertionMixincCstd�|_dS)Nztest exception)r5�TEST_EXCEPTIONrrrr�setUp�sz"ContextmanagerAssertionMixin.setUpcCs*|�|j�|�|j�|�|jd�dSr")�
assertTruer
�assertFalserrzr�r�mock_managerrrr�assertInWithManagerInvariants��z:ContextmanagerAssertionMixin.assertInWithManagerInvariantscCs*|�|j�|�|j�|�|j|�dSr")r�r
rrzr)rr�rrrr� assertAfterWithManagerInvariants�r�z=ContextmanagerAssertionMixin.assertAfterWithManagerInvariantscCs|�|d�dS)Nr<)r�r�rrr�'assertAfterWithManagerInvariantsNoError�s�zDContextmanagerAssertionMixin.assertAfterWithManagerInvariantsNoErrorcCs|�|j�|�|j�dSr")r�r*r�r+�rZmock_generatorrrr�assertInWithGeneratorInvariants��z<ContextmanagerAssertionMixin.assertInWithGeneratorInvariantscC�|�|j�|�|j�dSr"�r�r*r+r�rrr�)assertAfterWithGeneratorInvariantsNoError�r�zFContextmanagerAssertionMixin.assertAfterWithGeneratorInvariantsNoErrorcCs|j�r")r�rrrr�raiseTestException��z/ContextmanagerAssertionMixin.raiseTestExceptionNcCsx|�|j�|�|j�|dur|�|jd|j�t|j�}|�|jd|�|�|jd|�|�|jdd�dS)Nr=rr>)	r�r
rrzrr�rZassertIsInstanceZassertIsNot)rr��exc_typerrr�)assertAfterWithManagerInvariantsWithError�s
zFContextmanagerAssertionMixin.assertAfterWithManagerInvariantsWithErrorcCr�r"r�r�rrr�+assertAfterWithGeneratorInvariantsWithError�r�zHContextmanagerAssertionMixin.assertAfterWithGeneratorInvariantsWithErrorr")rrr r�r�r�r�r�r�r�r�r�rrrrr��s
�r�c@�DeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�NonexceptionalTestCasecCs,t��	Wd�dS1swYdSr"�r/rrrr�testInlineGeneratorSyntax�r�z0NonexceptionalTestCase.testInlineGeneratorSyntaxcCs8t�}|�Wd�n1swY|�|�dSr")r/r�)rr.rrr�testUnboundGenerator�s
�z+NonexceptionalTestCase.testUnboundGeneratorcCs>t��
}|�|�Wd�n1swY|�|�dSr"�r/r�r��rrGrrr�testInlineGeneratorBoundSyntax�s�z5NonexceptionalTestCase.testInlineGeneratorBoundSyntaxcCsBd}t��
}|�|�Wd�n1swY|�|�dSr"r�r�rrr�*testInlineGeneratorBoundToExistingVariable�s
�zANonexceptionalTestCase.testInlineGeneratorBoundToExistingVariablecCsDt��|_|�|j�Wd�n1swY|�|j�dSr")r/rGr�r�rrrr�(testInlineGeneratorBoundToDottedVariables
�z?NonexceptionalTestCase.testInlineGeneratorBoundToDottedVariablecCsVt�}|�}|�|�|�|�Wd�n1swY|�|�|�|�dSr")r/r�r�r�r�)rr.rGrrr�testBoundGenerators
�
z)NonexceptionalTestCase.testBoundGeneratorc	Cs�t�}|�E}t�}|�}|�|�|�|�|�|�|�|�Wd�n1s*wY|�|�|�|�|�|�|�|�Wd�n1sMwY|�|�|�|�dSr")r/r�r�r�r�)r�mock_arG�mock_b�barrrr�testNestedSingleStatementss 


�


�
z1NonexceptionalTestCase.testNestedSingleStatementsN)
rrr r�r�r�r�r�r�r�rrrrr��sr�c@r�)�NestedNonexceptionalTestCasecCs0tt���	Wd�dS1swYdSr"�r1r/rrrr�"testSingleArgInlineGeneratorSyntax#s"�z?NestedNonexceptionalTestCase.testSingleArgInlineGeneratorSyntaxcC�Ft�}t|��
}|�|�Wd�n1swY|�|�dSr"�r/r1r�r��r�mrGrrr�testSingleArgBoundToNonTuple'�

�z9NestedNonexceptionalTestCase.testSingleArgBoundToNonTuplecCr�r"r�r�rrr�2testSingleArgBoundToSingleElementParenthesizedList/r�zONestedNonexceptionalTestCase.testSingleArgBoundToSingleElementParenthesizedListcCrE)NcSs4tt���\}}Wd�dS1swYdSr"r�)rGr�rrr�shouldThrowValueError8s"�ziNestedNonexceptionalTestCase.testSingleArgBoundToMultipleElementTupleError.<locals>.shouldThrowValueError)rI�
ValueError)rr�rrr�-testSingleArgBoundToMultipleElementTupleError7szJNestedNonexceptionalTestCase.testSingleArgBoundToMultipleElementTupleErrorcCs^t�}t|�}|�|�|�|�|�Wd�n1swY|�|�|�|�dSr"�r/rBr�r�)rr'�mock_nestedrrr�testSingleArgUnbound=s
�
z1NestedNonexceptionalTestCase.testSingleArgUnboundcCs�t�}t�}t�}t|||�}|�|�|�|�|�|�|�|�|�Wd�n1s0wY|�|�|�|�|�|�|�|�dSr"r�)rr��n�or�rrr�testMultipleArgUnboundFs


�


z3NestedNonexceptionalTestCase.testMultipleArgUnboundcCs�tt�t�t��}|�\}}}|�|�|�|�|�|�|�|�Wd�n1s-wY|�|�|�|�|�|�|�|�dSr")rBr/r�r�r�r�)rr�r�r�r�rrr�testMultipleArgBoundUs�


�


z1NestedNonexceptionalTestCase.testMultipleArgBoundN)
rrr r�r�r�r�r�r�r�rrrrr�!s	r�c@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)NcsJ���_�������j����Wd�dS1swYdSr")�resourcer�r�r�r��cmrrrryfs


"�z;ExceptionalTestCase.testSingleResource.<locals>.shouldThrow)r/rIr5r�r�r�r{rr�r�testSingleResourceds

z&ExceptionalTestCase.testSingleResourcecs0t����fdd�}��t|����t�dS)Ncs4���_ddWd�dS1swYdS�Nr=r)r�rr�rrryqs
"�z@ExceptionalTestCase.testExceptionNormalized.<locals>.shouldThrow)r/rI�ZeroDivisionErrorr�r{rr�r�testExceptionNormalizedosz+ExceptionalTestCase.testExceptionNormalizedcsXt��t�����fdd�}��t|������������j����j�dS)Nc	s���?�_��#�_�����������j����j����Wd�n1s,wYWd�dSWd�dS1sDwYdSr"�rGr�r�r�r�r�r�r�rrrry|s


��"�zCExceptionalTestCase.testNestedSingleStatements.<locals>.shouldThrow)r/rIr5r�r�rGr�r{rr�rr�y�

z.ExceptionalTestCase.testNestedSingleStatementscsnt��t��t��������fdd�}��t|����������������j����j�dS)Ncsp��,\�_�_���������������j����j����Wd�dS1s1wYdSr")�
resource_a�
resource_br�r�r�r�Zcm_aZcm_br�rrrry�s



"�zOExceptionalTestCase.testMultipleResourcesInSingleStatement.<locals>.shouldThrow)r/rBrIr5r�r�r�r�r{rr�r�&testMultipleResourcesInSingleStatement�s



z:ExceptionalTestCase.testMultipleResourcesInSingleStatementcs|t��t��d�_���fdd�}��t|��������j����jd����j	����j
����jd�dS)Nc	s���4�_�������j������	�_Wd�n1s!wYWd�dSWd�dS1s9wYdSr")rGr�r�r�r�rr�rrry�s
��"�zPExceptionalTestCase.testNestedExceptionBeforeInnerStatement.<locals>.shouldThrow)r/r�rIr5r�r�rGrzr�r
rrr{rr�r�'testNestedExceptionBeforeInnerStatement�s
z;ExceptionalTestCase.testNestedExceptionBeforeInnerStatementcsXt��t�����fdd�}��t|������������j����j�dS)Nc	s���7�_���_�����������j����j�Wd�n1s(wY���Wd�dS1s<wYdSr"r�rr�rrry�s

�
"�zOExceptionalTestCase.testNestedExceptionAfterInnerStatement.<locals>.shouldThrow)	r/rIr5r�r�r�rGr�r�r{rr�r�&testNestedExceptionAfterInnerStatement�r�z:ExceptionalTestCase.testNestedExceptionAfterInnerStatementcsPtdd����fdd�}|�td��|�Wd�dS1s!wYdS)Ncs��dVdSr"rrrrrr����
z8ExceptionalTestCase.testRaisedStopIteration1.<locals>.cmc�$���td��1swYdS�N�	from with��
StopIterationr�r�rrry���zAExceptionalTestCase.testRaisedStopIteration1.<locals>.shouldThrowr�)rrVr�r{rr�r�testRaisedStopIteration1�s
"�z,ExceptionalTestCase.testRaisedStopIteration1csTGdd�dt���fdd�}|�td��|�Wd�dS1s#wYdS)Nc@rp)z8ExceptionalTestCase.testRaisedStopIteration2.<locals>.cmcSrMr"rrrrrr�rNzBExceptionalTestCase.testRaisedStopIteration2.<locals>.cm.__enter__cSrMr"rrrrrr�rNzAExceptionalTestCase.testRaisedStopIteration2.<locals>.cm.__exit__Nrtrrrrr��rvr�cr�r�r�rr�rrry�r�zAExceptionalTestCase.testRaisedStopIteration2.<locals>.shouldThrowr�)rUrVr�r{rr�r�testRaisedStopIteration2�s
"�z,ExceptionalTestCase.testRaisedStopIteration2csNtdd����fdd�}|�t��|�Wd�dS1s wYdS)Ncsr�r"rrrrrr��r�z8ExceptionalTestCase.testRaisedStopIteration3.<locals>.cmcs(���ttg���1s
wYdSr")�next�iterrr�rrry�s�zAExceptionalTestCase.testRaisedStopIteration3.<locals>.shouldThrow)rrIr�r{rr�r�testRaisedStopIteration3�s
"�z,ExceptionalTestCase.testRaisedStopIteration3cs(tdd����fdd�}|�t|�dS)Ncsr�r"rrrrrr��r�z8ExceptionalTestCase.testRaisedGeneratorExit1.<locals>.cmcr�r���
GeneratorExitrr�rrry�r�zAExceptionalTestCase.testRaisedGeneratorExit1.<locals>.shouldThrow)rrIr�r{rr�r�testRaisedGeneratorExit1�s
z,ExceptionalTestCase.testRaisedGeneratorExit1cr})Nc@rp)z8ExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cmcSrMr"rrrrrr�rNzBExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cm.__enter__cSrMr"rrrrrr�rNzAExceptionalTestCase.testRaisedGeneratorExit2.<locals>.cm.__exit__Nrtrrrrr��rvr�cr�r�r�rr�rrryr�zAExceptionalTestCase.testRaisedGeneratorExit2.<locals>.shouldThrow)rUrIr�r{rr�r�testRaisedGeneratorExit2�sz,ExceptionalTestCase.testRaisedGeneratorExit2cs\Gdd�dt����fdd�}|���fdd�}��t|���fdd�}��t|�dS)	Nc@r0)z0ExceptionalTestCase.testErrorsInBool.<locals>.cmcsG�fdd�d�}|�|_dS)NcseZdZ�fdd�ZdS)zGExceptionalTestCase.testErrorsInBool.<locals>.cm.__init__.<locals>.Boolcs��Sr"rr��bool_conversionrr�__bool__r�zPExceptionalTestCase.testErrorsInBool.<locals>.cm.__init__.<locals>.Bool.__bool__N)rrr r�rr�rr�Bool
sr��Zexit_result)rr�r�rr�rr	sz9ExceptionalTestCase.testErrorsInBool.<locals>.cm.__init__cS�dS)N�rrrrrrrNz:ExceptionalTestCase.testErrorsInBool.<locals>.cm.__enter__cSs|jSr"r��r�a�b�crrrrr�z9ExceptionalTestCase.testErrorsInBool.<locals>.cm.__exit__NrArrrrr�sr�c�<�dd�����d�Wd�dS1swYdS)NcSr�rrrrrr�<lambda>�zJExceptionalTestCase.testErrorsInBool.<locals>.trueAsBool.<locals>.<lambda>�Should NOT see this��failrr�rr�
trueAsBool�"�z8ExceptionalTestCase.testErrorsInBool.<locals>.trueAsBoolcr�)NcSr�rrrrrrr�r�zKExceptionalTestCase.testErrorsInBool.<locals>.falseAsBool.<locals>.<lambda>zShould raiser�rr�rr�falseAsBoolr�z9ExceptionalTestCase.testErrorsInBool.<locals>.falseAsBoolcr�)NcSsddSr�rrrrrr�!szJExceptionalTestCase.testErrorsInBool.<locals>.failAsBool.<locals>.<lambda>r�r�rr�rr�
failAsBool r�z8ExceptionalTestCase.testErrorsInBool.<locals>.failAsBool)rUrI�AssertionErrorr�)rr�r�r�rr�r�testErrorsInBoolsz$ExceptionalTestCase.testErrorsInBoolN)rrr r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�cs

r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�NonLocalFlowControlTestCasecCsXd}	|d7}t��
|d7}	Wd�q$1swY|d7}q|�|d�dS)NrTr=�
�d��r/rz�r�counterrrr�
testWithBreak(s��z)NonLocalFlowControlTestCase.testWithBreakcCsbd}	|d7}|dkrq)t��
|d7}	Wd�q1swY|d7}q|�|d�dS)NrTr=r>r�r��r�r�rrr�testWithContinue2s��z,NonLocalFlowControlTestCase.testWithContinuecCsdd�}|�|�d�dS)NcSsJd}	|d7}t��|d7}|Wd�S1swY|d7}q)NrTr=r�r�r�)r�rrrrG?s ��z7NonLocalFlowControlTestCase.testWithReturn.<locals>.foor�)rzr�rrr�testWithReturn>sz*NonLocalFlowControlTestCase.testWithReturncCs&dd�}t|��}|�|ddg�dS)Ncss:�t��dVdVWd�dS1swYdS)Nr��
r�rrrr�genJs
�"�z6NonLocalFlowControlTestCase.testWithYield.<locals>.genr�r)�listrz)rr�xrrr�
testWithYieldIs
z)NonLocalFlowControlTestCase.testWithYieldcCsld}z|d7}t��|d7}t�1swY|d7}Wnty.|�|d�YdSw|�d�dS)Nrr=r�r�r�zDidn't raise RuntimeError)r/r5rzr�r�rrr�
testWithRaiseQs��z)NonLocalFlowControlTestCase.testWithRaiseN)rrr r�r�rrrrrrrr�&s
r�c@r0)�AssignmentTargetTestCasecCsjdgd�i}t��"|dd<|�t|���dg�|�|ddjt�Wd�n1s.wYt��&t|���dd<|�t|���dg�|�|ddjt�Wd�n1s_wYt��|d<t|���}|��|�|ddg�Wd�n1s�wYGdd�d�}|�}t��|_|�t	|d�d�Wd�dS1s�wYdS)	Nr=�rr=r>rr>c@rZ)z;AssignmentTargetTestCase.testSingleComplexTarget.<locals>.CNr[rrrr�Cm�r	rGT)
r/rzr�keysrr)�values�sortrG�hasattr)r�targetsrr	�blahrrr�testSingleComplexTargetas&���
"�z0AssignmentTargetTestCase.testSingleComplexTargetcCs�Gdd�d�}dgd�i}|��!\|dd<|dd<|dd<|�|dgd�i�Wd�n1s4wY|��-\t|���dd<t|���dd<t|���dd<|�|dgd�i�Wd�n1slwY|��\|d<|d<|d	<|�|ddd	d��Wd�n1s�wYGd
d�d�}|�}|��$\|_|_|_|�|jd�|�|jd�|�|jd	�Wd�dS1s�wYdS)Nc@rp)z>AssignmentTargetTestCase.testMultipleComplexTargets.<locals>.CcSr�)N�r=r>r�rrrrrrtr�zHAssignmentTargetTestCase.testMultipleComplexTargets.<locals>.C.__enter__cSrMr"r�r�t�v�tbrrrrur�zGAssignmentTargetTestCase.testMultipleComplexTargets.<locals>.C.__exit__Nrtrrrrr	s�r	r=rrr>r)r�r>r=r�c@rZ)z>AssignmentTargetTestCase.testMultipleComplexTargets.<locals>.BNr[rrrr�B}r
r)rzrrZoneZtwoZthree)rr	rrrrrr�testMultipleComplexTargetsrs$&�>��"�z3AssignmentTargetTestCase.testMultipleComplexTargetscCsdttdd���!�^}}}|�|d�|�|ddg�|�|d�Wd�dS1s+wYdS)Nr=�r>r��)r�rangerzr�rrr�testWithExtendedTargets�s
"�z0AssignmentTargetTestCase.testWithExtendedTargetsN)rrr rrrrrrrr_src@rp)�ExitSwallowsExceptionTestCasecCsfGdd�d�}z|��ddWd�WdS1swYWdSty2|�d�YdSw)Nc@rp)zSExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallowcSrMr"rrrrrr�r�z]ExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallow.__enter__cSr�rrrrrrr�r�z\ExitSwallowsExceptionTestCase.testExitTrueSwallowsException.<locals>.AfricanSwallow.__exit__Nrtrrrr�AfricanSwallow�rrr=rz,ZeroDivisionError should have been swallowed�r�r�)rrrrr�testExitTrueSwallowsException�s
&��z;ExitSwallowsExceptionTestCase.testExitTrueSwallowsExceptioncCsdGdd�d�}z|��ddWd�n1swYWn
ty*YdSw|�d�dS)Nc@rp)zZExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallowcSrMr"rrrrrr�r�zdExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallow.__enter__cSr�rrrrrrr�r�zcExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowException.<locals>.EuropeanSwallow.__exit__Nrtrrrr�EuropeanSwallow�rr"r=rz)ZeroDivisionError should have been raisedr )rr"rrr�#testExitFalseDoesntSwallowException�s
���zAExitSwallowsExceptionTestCase.testExitFalseDoesntSwallowExceptionN)rrr r!r#rrrrr�s
rc@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(|dur|}||_||_d|_d|_dSr)r�gobbler
r)rrr%rrrr	�s
zNestedWith.Dummy.__init__cCsd|_|jSr)r
rrrrrr�szNestedWith.Dummy.__enter__cGsd|_||_|jrdSdSr)rr9r%rCrrrr�s
�zNestedWith.Dummy.__exit__rrArrrr�Dummy�s
r&c@r()zNestedWith.InitRaisescC�t��r"rrrrrrr	��zNestedWith.InitRaises.__init__Nr,rrrr�
InitRaises�r-r)c@rp)zNestedWith.EnterRaisescCr'r"rrrrrrr�r(z NestedWith.EnterRaises.__enter__cGrMr"rrCrrrr�r�zNestedWith.EnterRaises.__exit__Nrtrrrr�EnterRaises�rr*c@rp)zNestedWith.ExitRaisescCrMr"rrrrrr�r�zNestedWith.ExitRaises.__enter__cGr'r"rrrCrrrr�r(zNestedWith.ExitRaises.__exit__Nrtrrrr�
ExitRaises�rr+c	Cs�|���(}|���}|�|j�|�|j�Wd�n1s wYWd�n1s/wY|�|j�|�|j�dSr")r&r�r
r)rr�r�rrr�testNoExceptions�s��zNestedWith.testNoExceptionsc	Cszz*|���}|���Wd�n1swYWd�n1s$wYWnY|�|j�|�|j�dSr")r&r)r�r
r�rr�rrr�testExceptionInExprList�s���z"NestedWith.testExceptionInExprListc	Cs�z/|���!}|���
|�d�Wd�n1swYWd�n1s)wYWn	ty8Ynw|�d�|�|j�|�|j�dS)Nzbody of bad with executedzRuntimeError not reraised)r&r*r�r5r�r
rr-rrr�testExceptionInEnter�s����
zNestedWith.testExceptionInEnterc	Cs�d}|jdd��}|���
d}Wd�n1swYWd�n1s)wY|�|j�|�|j�|�|�|�|jdd�dS)NFT)r%r)r&r+r�r
rZassertNotEqualr9)rZ
body_executedr�rrr�testExceptionInExit�s��
zNestedWith.testExceptionInExitc	Cs�|jdd��C\}}|jdd��"\}}|�d|�|�d|�|�d|�|�d|�Wd�n1s4wYWd�dSWd�dS1sLwYdS)N)r=r>)r)r��r=r>r�r1)r&rz)rZa1Za2�b1�b2rrr�testEnterReturnsTuple�s
�P�z NestedWith.testEnterReturnsTupleN)
rrr rUr&r)r*r+r,r.r/r0r4rrrrr$�s		r$�__main__)�__doc__�
__author__Z	__email__r8Zunittest�collectionsr�
contextlibrrrrr'rUr)r/r1rBZTestCaserDr�r�r�r�r�rrr$r�mainrrrr�<module>s:
	$S/5�BD9,L�
© 2025 GrazzMean