Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyc


=Nc@sqdZddlZddlZddlmZddlmZddlmZdZ	defdYZ
dS(	s=
Python 2.5+ test cases for failures thrown into generators.
iN(tTestCase(tFailure(tdefercCs#yddWnt}nX|S(Nii(R(tf((sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pytgetDivisionFailures

tTwoPointFiveFailureTestscBsGeZdZdZdZdZdZdZdZRS(cst}tj}y|jWn|jnXgfd}d}tj|}||j|\}|jtj	|j
ddddS(sx
        inlineCallbacks that re-raise tracebacks into their deferred
        should not lose their tracebacsk.
        csj|dS(N(tappend(tresult(tfailures(sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyt
collect_error*scss	|VdS(N((td((sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pytic-sis1/0N(RRtDeferredtraiseExceptionterrbacktinlineCallbackst
addErrbacktassertEqualt	tracebackt
extract_tbtgetTracebackObject(tselfRR
R	Rt
newFailure((RsH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyttest_inlineCallbacksTracebackss			cCs6y|j|Wntk
r$nX|jddS(Ns<throwExceptionIntoGenerator should have raised StopIteration(tthrowExceptionIntoGeneratort
StopIterationtfail(RRtg((sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyt_throwIntoGenerator9s

csgfd}|}t}|jj||jddtjtddtjtjddddddS(sr
        It should be possible to throw the exception that a Failure
        represents into a generator.
        c3s7y	dVWnjtjnXjddS(Ns$Yield should have yielded exception.(Rtsystexc_infoR((Rtstuff(sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyt	generatorHs
	iiiis1/0N(	RtnextRRtZeroDivisionErrort
assertTruet
isinstanceRR(RR RR((RRsH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyt test_throwExceptionIntoGeneratorBs		
cset}|jgfd}|}|jj||j|gdS(s
        Within an exception handler, it should be possible to find the
        original Failure that caused the current exception (if it was
        caused by throwExceptionIntoGenerator).
        c3s7y	dVWnjtjnXjddS(NsNo exception sent to generator(RRt_findFailureR((t
foundFailuresR(sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyR ds
	N(RtcleanFailureR!RR(RRR R((RR'sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyttest_findFailureInGeneratorZs	
	
cst}|jgfd}|}|jj||jtdjdj|jdS(s
        When a Failure is constructed in the context of an exception
        handler that is handling an exception raised by
        throwExceptionIntoGenerator, the new Failure should be chained to that
        original Failure.
        c3s4y	dVWnjtnXjddS(NsNo exception sent to generator(RRR((RtnewFailures(sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyR s
	iiN(RR(R!RRtlentgetTraceback(RRR R((RR*sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyt,test_failureConstructionFindsOriginalFailuress	
	
cs?fd}|}|jt}j||dS(s
        When a generator reraises a different exception,
        L{Failure._findFailure} inside the generator should find the reraised
        exception rather than original one.
        c3sCyy	dVWngdnXWnjtjtnXdS(Ni(tassertIsInstanceRtvaluet
IndexError((R(sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyR s	N(R!RR(RR RR((RsH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyt test_ambiguousFailureInGenerators
	
	cCs]d}|}|jt}y|j||Wn|jtjtnXdS(s
        When a generator reraises a different exception,
        L{Failure._findFailure} above the generator should find the reraised
        exception rather than original one.
        cssy	dVWngdnXdS(Ni((((sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyR s	N(R!RRR.RR/R0(RR RR((sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyt"test_ambiguousFailureFromGenerators		
	(	t__name__t
__module__RRR%R)R-R1R2(((sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyRs							(t__doc__RRttwisted.trial.unittestRttwisted.python.failureRttwisted.internetRRR(((sH/usr/lib/python2.7/dist-packages/twisted/test/generator_failure_tests.pyt<module>s