ϪfddlmZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z ddlmZddlmZmZGd d eZGd d eZy) ) annotationsN)skipIf) implementer)Failure) IReporter ITestCase) pyunitcases)PyUnitResultAdapterSynchronousTestCaseceZdZddZddZy)PyUnitTestTestscltjd|_t|j|_y)N test_pass)r PyUnitTestoriginalrtestselfs F/usr/lib/python3/dist-packages/twisted/trial/test/test_pyunitcompat.pysetUpzPyUnitTestTests.setUps$#..{; dmm, ch|jt|j|jdy)zW Tests must be callable in order to be used with Python's unittest.py. z is not callable.N) assertTruecallablerrs r test_callablezPyUnitTestTests.test_callables' + }.StubReporterz A reporter which records data about calls made to it. @ivar errors: Errors passed to L{addError}. @ivar failures: Failures passed to L{addFailure}. c g|_g|_y)N)errorsfailuresrs r__init__zaPyUnitResultTests.test_dontUseAdapterWhenReporterProvidesIReporter..StubReporter.__init__Fs-/ ,. rcyz- Do nothing. Nr"rrs r startTestzbPyUnitResultTests.test_dontUseAdapterWhenReporterProvidesIReporter..StubReporter.startTestJrcyr6r"r7s rstopTestzaPyUnitResultTests.test_dontUseAdapterWhenReporterProvidesIReporter..StubReporter.stopTestOr9rc:|jj|y)z3 Record the error. N)r2append)rrerrors raddErrorzaPyUnitResultTests.test_dontUseAdapterWhenReporterProvidesIReporter..StubReporter.addErrorTs ""5)rNr)robjectrr)rr@r>rrr)rr r!r,r4r8r;r?r"rr StubReporterr0=s  /     *rrAr+rN)rrr-runassertIsInstancer2r)rrArresults r0test_dontUseAdapterWhenReporterProvidesIReporterzBPyUnitResultTests.test_dontUseAdapterWhenReporterProvidesIReporter7s\ Y  * *  *8~~j)  fmmA.8rc(Gddt}|d}tj}|j||j |j |j d|j|j |jy)NceZdZdZddZy)3PyUnitResultTests.test_success..SuccessTestFcd|_yNTr)ss rr+z.SuccessTest.test_fooc rNrrr r!r*r+r"rr SuccessTestrH`s C rrOr+r() r pyunit TestResultrBrr* assertEqualtestsRun wasSuccessful)rrOrrDs r test_successzPyUnitResultTests.test_success_sn -  :&""$  ! FOO, ,,./rcrGddt}|d}tj}|j||j |j |j d|j|j dt|j|j|jy)NceZdZdZddZy)3PyUnitResultTests.test_failure..FailureTestFc4d|_|jdy)NTzboom!)r*failrKs rr+z.FailureTest.test_foorswrNrrNr"rr FailureTestrXos C rr[r+r() r rPrQrBrr*rRrSlenr3 assertFalserT)rr[rrDs r test_failurezPyUnitResultTests.test_failurens - :&""$  ! FOO, C01 --/0rcf|jd}tj}|j||j |j |j d|j|j dt|j|j|jy)Nr+r() r-rPrQrBrr*rRrSr\r2r]rT)rrrDs r test_errorzPyUnitResultTests.test_errors~~~j)""$  ! FOO, C ./ --/0rcrGddt}|d}tj}|j||j |j |j d|j|j dt|j|j |jy)Nc eZdZdZddZddZy)4PyUnitResultTests.test_setUpError..ErrorTestFcddz yNr(rr"rs rrz:PyUnitResultTests.test_setUpError..ErrorTest.setUps Arcd|_yrJr)rKs rr+z=PyUnitResultTests.test_setUpError..ErrorTest.test_foorMrNr)rr r!r*rr+r"rrr-rcsC  rr-r+r() r rPrQrBr]r*rRrSr\r2rT)rr-rrDs rtest_setUpErrorz!PyUnitResultTests.test_setUpErrors + $""$  " FOO, C ./ --/0rcN ddz t j }t |}|j||j|jdddjtjy#t$r!tj}t}YwxYw)z Errors added through the L{PyUnitResultAdapter} have the same traceback information as if there were no adapter at all. r(rN) ZeroDivisionErrorsysexc_inforrPrQr r?rRr2join tracebackformat_exception)rrlfpyresultrDs rtest_tracebackFromFailurez+PyUnitResultTests.test_tracebackFromFailures   E$$&$X.a   OOA q !2779+E+Ex+P#Q ! ||~H A sA::'B$#B$cGddt}|d}tj}|j||jJdj t j|jd}dj |jdd jdd }|j|j|t| djy) zG As test_tracebackFromFailure, but covering more code. ceZdZdZddZy)3PyUnitResultTests.test_traceback..ErrorTestNc^ ddz y#t$rtj|_wxYwre)rjrkrlrs rr+z.ErrorTest.test_foos-E($'LLNDMs$,r)rr r!rlr+r"rrr-rus H rr-r+Nri rr() r rPrQrBrlrmrn format_tbr2 splitlinesrRstripr\)rr-rrDexpected_stackobserved_stacks rtest_tracebackz PyUnitResultTests.test_tracebacks  + $""$ }}(((!4!4T]]15E!FG6==#3A#6#A#A#CCR#HI   "NC4G3G3I$J$P$P$R rc ddz j t j }t|}|j||djtj}|j|jddjd|jdy#t$r!tj}t}YwxYw)z Errors added through the L{PyUnitResultAdapter} have the same traceback information as if there were no adapter at all, even if the Failure that held the information has been cleaned. r(rriz$ZeroDivisionError: division by zero N)rjrkrlr cleanFailurerPrQr r?rmrnrorRr2endswith)rrlrprqrDtbacks rtest_tracebackFromCleanFailurez0PyUnitResultTests.test_tracebackFromCleanFailures   E $$&$X.a  22H=>  OOA q ! * *+R S NNB C ! ||~H A sB**'CCcGddt}|d}tj}|j||j |j |dfgy)zw Skips using trial's skipping functionality are reported as skips in the L{pyunit.TestResult}. c,eZdZeddddZy)2PyUnitResultTests.test_trialSkip..SkipTestT Let's skip!cddz yrer"rs r test_skipz.SkipTest.test_skip ArNr)rr r!rrr"rrSkipTestrs D- ( ) rrrrNr rPrQrBrRskippedrrrrDs rtest_trialSkipz PyUnitResultTests.test_trialSkipsQ  *   $""$  4*?)@ArcGddt}|d}tj}|j||j |j |dfgy)zx Skips using pyunit's skipping functionality are reported as skips in the L{pyunit.TestResult}. c>eZdZejdddZy)3PyUnitResultTests.test_pyunitSkip..SkipTestskippycddz yrer"rs rrz=PyUnitResultTests.test_pyunitSkip..SkipTest.test_skiprrNr)rr r!rPskiprr"rrrrs V[[ " # rrrrNrrs rtest_pyunitSkipz!PyUnitResultTests.test_pyunitSkipsQ  *   $""$  4*:);rsC# &*5*K P) Pc=+c=r