403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_with.cpython-36.pyc
3

x2_[g�@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�rDej�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__��3/opt/alt/python36/lib64/python3.6/test/test_with.pyrszMockContextManager.__init__cCsd|_tj|�S)NT)rr�	__enter__)rrrrrszMockContextManager.__enter__cCs"d|_|||f|_tj||||�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__c	Csn|jdk	rtd��t�|_g}y.x(|jD]}|j|j��|jj|�q(WWn|jtj	��sd�YnX|S)NzContext is not reentrant)
r$�RuntimeErrorrr#�appendr�
appendleftr�sys�exc_info)r�vars�mgrrrrr;s
zNested.__enter__c
Gsh|}x6|jD],}y|j|�r d}Wqtj�}YqXqWd|_||k	rd|d|d�j|d��dS)Nr��)NNN)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|_tj|�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�}|jt|�dS)Nc	Sst�WdQRXdS)N)�foorrrr�fooNotDeclaredlsz5FailureTestCase.testNameError.<locals>.fooNotDeclared)�assertRaises�	NameError)rr2rrr�
testNameErrorkszFailureTestCase.testNameErrorcs.Gdd�dt���fdd�}|jtd|�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�}|jtd|�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�}|jtd|�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�}|jt||�dS)NcSst|dd�dS)N�Zsingle)�compile)�srrr�shouldRaiseSyntaxError�szGFailureTestCase.assertRaisesSyntaxError.<locals>.shouldRaiseSyntaxError)r3�SyntaxError)rZcodestrrErrr�assertRaisesSyntaxError�sz'FailureTestCase.assertRaisesSyntaxErrorcCs|jd�|jd�dS)Nzwith mock as None:
  passzwith mock as (None):
  pass)rG)rrrr�testAssignmentToNoneError�s
z)FailureTestCase.testAssignmentToNoneErrorcCs|jd�|jd�dS)Nzwith mock as None,:
  passzwith mock as (None,):
  pass)rG)rrrr�,testAssignmentToTupleOnlyContainingNoneError�s
z<FailureTestCase.testAssignmentToTupleOnlyContainingNoneErrorcCs|jd�dS)Nz%with mock as (foo, None, bar):
  pass)rG)rrrr�(testAssignmentToTupleContainingNoneError�sz8FailureTestCase.testAssignmentToTupleContainingNoneErrorcs<Gdd�dt����fdd�}�jt|��j�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�}|jt|�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�|j|j�|j|jd�dS)N)�
assertTruer�assertFalser	rMr
)r�mock_managerrrr�assertInWithManagerInvariants�sz:ContextmanagerAssertionMixin.assertInWithManagerInvariantscCs*|j|j�|j|j�|j|j|�dS)N)rUrr	rMr
)rrWr
rrr� assertAfterWithManagerInvariants�sz=ContextmanagerAssertionMixin.assertAfterWithManagerInvariantscCs|j|d�dS)N)NNN)rY)rrWrrr�'assertAfterWithManagerInvariantsNoError�szDContextmanagerAssertionMixin.assertAfterWithManagerInvariantsNoErrorcCs|j|j�|j|j�dS)N)rUrrVr)r�mock_generatorrrr�assertInWithGeneratorInvariants�sz<ContextmanagerAssertionMixin.assertInWithGeneratorInvariantscCs|j|j�|j|j�dS)N)rUrr)rr[rrr�)assertAfterWithGeneratorInvariantsNoError�szFContextmanagerAssertionMixin.assertAfterWithGeneratorInvariantsNoErrorcCs
|j�dS)N)rS)rrrr�raiseTestException�sz/ContextmanagerAssertionMixin.raiseTestExceptionNcCsx|j|j�|j|j�|dkr>|j|jd|j�t|j�}|j|jd|�|j|jd|�|j|jdd�dS)Nr,rr-)	rUrr	rMr
rSrZassertIsInstanceZassertIsNot)rrW�exc_typerrr�)assertAfterWithManagerInvariantsWithError�s
zFContextmanagerAssertionMixin.assertAfterWithManagerInvariantsWithErrorcCs|j|j�|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|j|�dS)N)r!rZ)rr rrr�testUnboundGenerator�s
z+NonexceptionalTestCase.testUnboundGeneratorc	Cs*t��}|j|�WdQRX|j|�dS)N)r!r\r])rr1rrr�testInlineGeneratorBoundSyntax�sz5NonexceptionalTestCase.testInlineGeneratorBoundSyntaxc	Cs.d}t��}|j|�WdQRX|j|�dS)N)r!r\r])rr1rrr�*testInlineGeneratorBoundToExistingVariable�szANonexceptionalTestCase.testInlineGeneratorBoundToExistingVariablec	Cs0t��|_|j|j�WdQRX|j|j�dS)N)r!r1r\r])rrrr�(testInlineGeneratorBoundToDottedVariables
z?NonexceptionalTestCase.testInlineGeneratorBoundToDottedVariablec	CsBt�}|�}|j|�|j|�WdQRX|j|�|j|�dS)N)r!r\rXr]rZ)rr r1rrr�testBoundGenerators

z)NonexceptionalTestCase.testBoundGeneratorcCs�t�}|�l}t�}|�.}|j|�|j|�|j|�|j|�WdQRX|j|�|j|�|j|�|j|�WdQRX|j|�|j|�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|��}|j|�WdQRX|j|�dS)N)r!r"rXrZ)r�mr1rrr�testSingleArgBoundToNonTuple's
z9NestedNonexceptionalTestCase.testSingleArgBoundToNonTuplec	Cs2t�}t|��}|j|�WdQRX|j|�dS)N)r!r"rXrZ)rror1rrr�2testSingleArgBoundToSingleElementParenthesizedList/s
zONestedNonexceptionalTestCase.testSingleArgBoundToSingleElementParenthesizedListcCsdd�}|jt|�dS)Nc	Sstt���
\}}WdQRXdS)N)r"r!)r1rkrrr�shouldThrowValueError8sziNestedNonexceptionalTestCase.testSingleArgBoundToMultipleElementTupleError.<locals>.shouldThrowValueError)r3�
ValueError)rrrrrr�-testSingleArgBoundToMultipleElementTupleError7szJNestedNonexceptionalTestCase.testSingleArgBoundToMultipleElementTupleErrorc	CsJt�}t|�}|�|j|�|j|�WdQRX|j|�|j|�dS)N)r!r/rXrZ)rr�mock_nestedrrr�testSingleArgUnbound=s

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





z3NestedNonexceptionalTestCase.testMultipleArgUnboundc
Cs|tt�t�t��}|�4\}}}|j|�|j|�|j|�|j|�WdQRX|j|�|j|�|j|�|j|�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�}�jt|��j���j�j�dS)Nc	s4��&�_�j���j�j��j�WdQRXdS)N)�resourcerXr\r^r)�cmrrrrLfs
z;ExceptionalTestCase.testSingleResource.<locals>.shouldThrow)r!r3r%r`rar|)rrLr)r}rr�testSingleResourceds

z&ExceptionalTestCase.testSingleResourcecs0t����fdd�}�jt|��j�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�}�jt|��j���j���j�j��j�j�dS)Ncs\��N�_��<�_�j���j���j�j��j�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�}�jt|��j���j���j���j�j��j�j�dS)Nc
sZ��L\�_�_�j���j���j���j�j��j�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�}�jt|��j���j�j��j�jd��j�j	��j�j
��j�jd�dS)NcsF��8�_�j���j�j��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�}�jt|��j���j���j�j��j�j�dS)Ncs\��N�_��4�_�j���j���j�j��j�j�WdQRX�j�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�}|jtd��|jt|�WdQRXdS)Ncss
dVdS)Nrrrrrr}�sz8ExceptionalTestCase.testRaisedStopIteration1.<locals>.cmc	s���td��WdQRXdS)Nz	from with)�
StopIterationr)r}rrrL�szAExceptionalTestCase.testRaisedStopIteration1.<locals>.shouldThrowr�)r�assertWarnsRegex�DeprecationWarningr3r�)rrLr)r}r�testRaisedStopIteration1�sz,ExceptionalTestCase.testRaisedStopIteration1cs,Gdd�dt���fdd�}|jt|�dS)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>.shouldThrow)r8r3r�)rrLr)r}r�testRaisedStopIteration2�sz,ExceptionalTestCase.testRaisedStopIteration2c
s@tdd����fdd�}|jtd��|jt|�WdQRXdS)Ncss
dVdS)Nrrrrrr}�sz8ExceptionalTestCase.testRaisedStopIteration3.<locals>.cmc
s"���ttg���WdQRXdS)N)�next�iterr)r}rrrL�szAExceptionalTestCase.testRaisedStopIteration3.<locals>.shouldThrowr�)rr�r�r3r�)rrLr)r}r�testRaisedStopIteration3�sz,ExceptionalTestCase.testRaisedStopIteration3cs(tdd����fdd�}|jt|�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�}|jt|�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�}�jt|���fdd�}�jt|�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�rrsz9ExceptionalTestCase.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����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�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|j|d�dS)Nrr,�
�d�)r!rM)r�counterrrr�
testWithBreak'sz)NonLocalFlowControlTestCase.testWithBreakc	CsPd}x:|d7}|dkrPt��|d7}wWdQRX|d7}qW|j|d�dS)Nrr,r-r�r��)r!rM)rr�rrr�testWithContinue1sz,NonLocalFlowControlTestCase.testWithContinuecCsdd�}|j|�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|��}|j|ddg�dS)Nc	ss"t��dVdVWdQRXdS)Nr��
)r!rrrr�genIsz6NonLocalFlowControlTestCase.testWithYield.<locals>.genr�r�)�listrM)rr��xrrr�
testWithYieldHs
z)NonLocalFlowControlTestCase.testWithYieldcCsfd}y2|d7}t��|d7}t�WdQRX|d7}Wn tk
rV|j|d�YnX|jd�dS)Nrr,r�r�r�zDidn't raise RuntimeError)r!r%rMr�)rr�rrr�
testWithRaisePsz)NonLocalFlowControlTestCase.testWithRaiseN)rrrr�r�r�r�r�rrrrr�%s

r�c@seZdZdd�Zdd�ZdS)�AssignmentTargetTestCasec Csddddgi}t��:|dd<|jt|j��dg�|j|ddjt�WdQRXt��Bt|j��dd<|jt|j��dg�|j|ddjt�WdQRXt��.|d<t|j��}|j�|j|ddg�WdQRXGdd�d�}|�}t��|_|jt	|d�d�WdQRXdS)Nr,rr-c@seZdZdS)z;AssignmentTargetTestCase.testSingleComplexTarget.<locals>.CN)rrrrrrr�Clsr�r1T)
r!rMr��keysr
r�values�sortr1�hasattr)r�targetsr�r��blahrrr�testSingleComplexTarget`s  
z0AssignmentTargetTestCase.testSingleComplexTargetc CsXGdd�d�}ddddgi}|��:\|dd<|dd<|dd<|j|ddddgi�WdQRX|��R\t|j��dd<t|j��dd<t|j��dd<|j|ddddgi�WdQRX|��,\|d<|d<|d<|j|dddd��WdQRXGdd	�d	�}|�}|��<\|_|_|_|j|jd�|j|jd�|j|jd�WdQRXdS)
Nc@seZdZdd�Zdd�ZdS)z>AssignmentTargetTestCase.testMultipleComplexTargets.<locals>.CcSsdS)Nr,r-r�)r,r-r�r)rrrrrsszHAssignmentTargetTestCase.testMultipleComplexTargets.<locals>.C.__enter__cSsdS)Nr)r�t�v�tbrrrrtszGAssignmentTargetTestCase.testMultipleComplexTargets.<locals>.C.__exit__N)rrrrrrrrrr�rsr�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�testMultipleComplexTargetsqs& > z3AssignmentTargetTestCase.testMultipleComplexTargetsN)rrrr�r�rrrrr�^sr�c@seZdZdd�Zdd�ZdS)�ExitSwallowsExceptionTestCasecCsPGdd�d�}y|��ddWdQRXWntk
rJ|jd�YnXdS)Nc@seZdZdd�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�sr�r,rz,ZeroDivisionError should have been swallowed)rr�)rr�rrr�testExitTrueSwallowsException�sz;ExitSwallowsExceptionTestCase.testExitTrueSwallowsExceptioncCsPGdd�d�}y|��ddWdQRXWntk
r@YnX|jd�dS)Nc@seZdZdd�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�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�szNestedWith.InitRaises.__init__N)rrrrrrrr�
InitRaises�sr�c@seZdZdd�Zdd�ZdS)zNestedWith.EnterRaisescCs
t��dS)N)r%)rrrrr�sz NestedWith.EnterRaises.__enter__cGsdS)Nr)rr)rrrr�szNestedWith.EnterRaises.__exit__N)rrrrrrrrr�EnterRaises�sr�c@seZdZdd�Zdd�ZdS)zNestedWith.ExitRaisescCsdS)Nr)rrrrr�szNestedWith.ExitRaises.__enter__cGs
t��dS)N)r%)rr)rrrr�szNestedWith.ExitRaises.__exit__N)rrrrrrrrr�
ExitRaises�sr�cCs\|j��2}|j��}|j|j�|j|j�WdQRXWdQRX|j|j�|j|j�dS)N)r�rUrr	)rr�r�rrr�testNoExceptions�s
 zNestedWith.testNoExceptionscCsVy,|j��}|j��WdQRXWdQRXWnYnX|j|j�|j|j�dS)N)r�r�rUrr	)rr�rrr�testExceptionInExprList�sz"NestedWith.testExceptionInExprListcCsry6|j��$}|j��|jd�WdQRXWdQRXWntk
rJYnX|jd�|j|j�|j|j�dS)Nzbody of bad with executedzRuntimeError not reraised)r�r�r�r%rUrr	)rr�rrr�testExceptionInEnter�s"
zNestedWith.testExceptionInEntercCsld}|jdd��}|j��
d}WdQRXWdQRX|j|j�|j|j�|j|�|j|jdd�dS)NFT)r�r)r�r�rUrr	ZassertNotEqualr))rZ
body_executedr�rrr�testExceptionInExit�s
zNestedWith.testExceptionInExitcCsl|jdd��V\}}|jdd��:\}}|jd|�|jd|�|jd|�|jd|�WdQRXWdQRXdS)Nr,r-)rr��)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/5AC9&L


Youez - 2016 - github.com/yon3zu
LinuXploit