Your IP : 172.28.240.42


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


=Nc@s|dZddlZddlZddlZddlZddlmZmZddlm	Z	m
Z
mZmZddl
mZmZddlmZdd-dYZd	e	jfd
YZde	jefdYZd
e	jefdYZde	jefdYZde	jefdYZde	jefdYZde	jfdYZde	jfdYZde	jfdYZdd.dYZdee	jfdYZdee	jfd YZd!e	jfd"YZ d#e	jfd$YZ!d%e	jfd&YZ"d'e	jfd(YZ#d)e	jfd*YZ$d+e	jfd,YZ%dS(/s(
Tests for the behaviour of unit tests.
iN(tdefertreactor(tunittesttrunnertreportertutil(t	erroneoustsuppression(tLoggingReportertResultsTestMixincBs#eZdZdZdZRS(cCs7tj|_|jj||_tj|_dS(N(Rt
TestLoadertloadert	loadClasstsuiteRt
TestResult(tselfR
((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt	loadSuitescCs\|j|jj|j|jjg|j|jjg|j|jjgdS(N(t
failUnlessRt
wasSuccessfultassertEqualterrorstfailurestskips(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_setUpscCsC|j|jj||j|j|j|jj|dS(N(RR
tcountTestCasesRttestsRun(RtnumTests((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pytassertCounts(t__name__t
__module__RRR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR	s		tTestSuccesscBsDeZdZdZdZdZdZdZdZRS(s:
    Test that successful tests are reported as such.
    cCstj|_dS(N(RRtresult(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pytsetUp(scCsdS(s9
        A successful test, used by other tests.
        N((R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_successful,scCsv|j|jd|j|jg|j|jg|j|jg|j|jg|j|jgdS(Ni(Rt	successesRRtexpectedFailurestunexpectedSuccessesR(RttestR((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pytassertSuccessful2scCs3td}|j|j|j||jdS(s
        Test that when a successful test is run, it is reported as a success,
        and not as any other kind of result.
        R!N(RtrunRR&(RR%((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_successfulIsReported;scCs3tj}|j|j|j||jdS(s{
        Test that L{unittest.TestCase} itself can be instantiated, run, and
        reported as being successful.
        N(RtTestCaseR'RR&(RR%((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_defaultIsSuccessfulEscCsbtd}tj|}|j|j|j||j~tj|j|ddS(sF
        Test that no reference is kept on a successful test.
        R!N(
RtweakreftrefR'RR&tgctcollecttassertIdenticaltNone(RR%R,((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_noReferenceOs
(	RRt__doc__R R!R&R(R*R1(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR#s					
	
tTestSkipMethodscBsgeZdejfdYZdejfdYZdZdZdZdZ	dZ
RS(	t
SkippingTestscBs5eZdZdZde_dZde_RS(cCstjddS(Ntskip1(RtSkipTest(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_skip1_scCstddS(NsI should not get raised(tRuntimeError(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_skip2bstskip2cCs|jddS(NsI should not fail(tfail(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_skip3fstskip3(RRR7R9tskipR<(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR4^s
				t
SkippingSetUpcBs#eZdZdZdZRS(cCstjddS(Nt	skipSetUp(RR6(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR kscCsdS(N((R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_1nscCsdS(N((R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_2qs(RRR RARB(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR?js		cCs|jtjdS(N(RR3R4(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR tscCs|jddS(Ni(R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_countingwscCsr|j|j|j|jj|j|jjg|j|jjg|jt|jjddS(Ni(	R
RRRRRRtlenR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_resultszs
cCs|jtj|j|j|j|jj|j|jjg|j|jj	g|jt
|jjddS(Ni(RR3R?R
RRRRRRRDR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRscCs]|j|jd}x@|jjD]2\}}|j|jt|t|q#WdS(Nttest_(R
RRRtshortDescriptionRDtstr(RtprefixR%treason((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_reasonss
(RRRR)R4R?R RCRERRK(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR3]s
				tTestSkipClassescBsNeZdejfdYZdZdZdZdZdZ	RS(tSkippedClasscBsDeZdZdZdZdZde_dZdZRS(tclasscCst|j_dS(N(tTruet	__class__t	_setUpRan(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR scCstjddS(NR5(RR6(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR7scCstddS(NsOught to skip me(R8(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR9sR:cCsdS(N((R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR<scCstddS(NsSkip me too(R8(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_skip4s(RRR>R R7R9R<RR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRMs					cCs |jtjttj_dS(N(RRLRMtFalseRQ(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR scCs|jddS(sP
        Skipped test methods still contribute to the total test count.
        iN(R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRCscCs'|j|j|jtjjdS(sP
        The C{setUp} method is not called if the class is set to skip.
        N(R
RtassertFalseRLRMRQ(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_setUpRanscCsr|j|j|j|jj|j|jjg|j|jjg|jt|jjddS(s
        Skipped test methods don't cause C{wasSuccessful} to return C{False},
        nor do they contribute to the C{errors} or C{failures} of the reporter.
        They do, however, add elements to the reporter's C{skips} list.
        iN(	R
RRRRRRRDR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyREs
cCs[|j|jddddg}g|jjD]\}}|^q/}|j||dS(s
        Test methods which raise L{unittest.SkipTest} or have their C{skip}
        attribute set to something are skipped.
        RNR:N(R
RRR(RtexpectedReasonsR%RJtreasonsGiven((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRKs%(
RRRR)RMR RCRURERK(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRLs				
tTestTodocBsNeZdejfdYZdZdZdZdZdZ	RS(t	TodoTestscBs>eZdZde_dZde_dZde_RS(cCs|jddS(Nsdeliberate failure(R;(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_todo1sttodo1cCstddS(Nsdeliberate error(R8(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_todo2sttodo2cCsdS(sunexpected successN((R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_todo3sttodo3(RRRZttodoR\R^(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRYs					cCs|jtjdS(N(RRXRY(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR scCs|jddS(Ni(R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRCscCs|j|j|j|jj|j|jjg|j|jjg|j|jjg|jt|jj	d|jt|jj
ddS(Nii(R
RRRRRRRRDR#R$(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyREscCs[|j|jddg}g|jjD]\}}}|j^q)}|j||dS(NR[R](R
RR#RJR(RRVtttetrRW((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_expectedFailuress
(cCsU|j|jdg}g|jjD]\}}|j^q&}|j||dS(NR_(R
RR$RJR(RRVRaRcRW((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_unexpectedSuccessess
	%(
RRRR)RYR RCRERdRe(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRXs
					t
TestTodoClasscBsWeZdejfdYZde_dZdZdZdZ	dZ
RS(t	TodoClasscBs>eZdZde_dZdZde_dZRS(cCsdS(N((R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRZstmethodcCsdS(N((R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR\scCs|jddS(NsDeliberate Failure(R;(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR^scCs|jddS(NsDeliberate Failure(R;(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_todo4s(RRRZR`R\R^Ri(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRgs					RNcCs|jtjdS(N(RRfRg(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR 
scCs|jddS(Ni(R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRC
scCs|j|j|j|jj|j|jjg|j|jjg|j|jjg|jt|jj	d|jt|jj
ddS(Ni(R
RRRRRRRRDR#R$(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyREscCs[|j|jddg}g|jjD]\}}}|j^q)}|j||dS(NRhRN(R
RR#RJR(RRVRaRbRcRW((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRds
(cCsX|j|jddg}g|jjD]\}}|j^q)}|j||dS(NRhRN(R
RR$RJR(RRVRaRcRW((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRe s
%(RRRR)RgR`R RCRERdRe(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRfs						tTestStrictTodocBsNeZdejfdYZdZdZdZdZdZ	RS(tTodoscBseZdZedfe_dZeefdfe_dZedfe_dZee	fdfe_dZ
ejd	fe
_d
Z
edfe
_dZed
fe_RS(cCs
tddS(Nsexpected failure(R8(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRZ*sR[cCs
tddS(Nsexpected failure(R8(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR\.sR]cCs
tddS(Nswe had no idea!(R8(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR^2sR_cCs
tddS(Nswe had no idea!(R8(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRi6sttodo4cCs|jddS(Nsdeliberate failure(R;(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_todo5:sttodo5cCs|jddS(Nsdeliberate failure(R;(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_todo6>sttodo6cCsdS(N((R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_todo7Bsttodo7(RRRZR8R`R\tOSErrorR^RitSyntaxErrorRmRtFailTestRoRq(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRk)s							cCs|jtjdS(N(RRjRk(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR FscCs|jddS(Ni(R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRCIscCs|j|j|j|jj|jt|jjd|jt|jjd|jt|jjd|jt|jj	d|j|jj
gdS(Niii(R
RtfailIfRRRDRRR#R$R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRELscCs^|j|jdddg}g|jjD]\}}}|j^q,}|j||dS(NR[R]Rn(R
RR#RJR(RRVRaRbRct
reasonsGotten((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRdUs
(cCsg|j|jtgdfg}g|jjD]\}}|j|jf^q/}|j||dS(NRr(R
RR8R$RRJR(RRVRaRcRw((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRe\s
.(
RRRR)RkR RCRERdRe(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRj(s					tTestCleanupcBs#eZdZdZdZRS(cCs+tjtj|_tj|_dS(N(RtReportertStringIORRR
R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR gscCs|jjtjj}|j|j|j|jj|j	|jj
d|jjdd}|j|j
tjdS(sm
        Trial reports a L{util.DirtyReactorAggregateError} if a test leaves
        sockets behind.
        iiN(Rt
loadMethodRtSocketOpenTestttest_socketsLeftOpenR'RRvRRR"RRtcheckRtDirtyReactorAggregateError(RR
tfailure((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttestLeftoverSocketsls	cCs|tjd}|j|j|j|jj|jjdd}|j|jjd|j	|j
tjdS(s
        Trial reports a L{util.DirtyReactorAggregateError} and fails the test
        if a test leaves a L{DelayedCall} hanging.
        ttest_leftoverPendingCallsiiN(
RtReactorCleanupTestsR'RRvRRRR"RR~RR(RR
R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttestLeftoverPendingCalls}s(RRR RR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRxes		tFixtureTestcBs)eZdZdZdZdZRS(sI
    Tests for broken fixture helper methods (e.g. setUp, tearDown).
    cCs"tj|_tj|_dS(N(RRyRR
R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR scCsl|jjtjj|j|jt|jjdk|jt	|jjddj
tjdS(sO
        When setUp fails, the error is recorded in the result object.
        iiN(RRRtTestFailureInSetUpR'Rtassert_RDRt
isinstancetvaluetFoolishError(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttestBrokenSetUpscCsr|jjtj}|j|j|jj}|jt|dk|jt	|ddj
tjdS(sR
        When tearDown fails, the error is recorded in the result object.
        iiN(RRRtTestFailureInTearDownR'RRRRDRRR(RR
R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttestBrokenTearDowns
(RRR2R RR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRs		
tSuppressionTestcBs>eZdZdZdZdZdZdZRS(cCs|jtjdS(N(R'RR(RR
((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pytrunTestsscCstj|_dS(N(RR
R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR scCs|j|jjtjj|jtjjg}|j|ddtj	|j|ddtj
|jt|ddS(s
        A suppression set on a test method prevents warnings emitted by that
        test method which the suppression matches from being emitted.
        itmessageiiN(RRR{RtTestSuppressionttestSuppressMethodt
flushWarningst_emitRtCLASS_WARNING_MSGtMODULE_WARNING_MSGRD(Rt
warningsShown((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_suppressMethodscCs|j|jjtjj|jtjjg}|j|ddtj	|j|ddtj
|jt|ddS(s
        A suppression set on a L{TestCase} subclass prevents warnings emitted
        by any test methods defined on that class which match the suppression
        from being emitted.
        iRiiN(RRR{RRttestSuppressClassRRRtMETHOD_WARNING_MSGRRD(RR((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_suppressClassscCs|j|jjtjj|jtjjg}|j	|ddtj
|j	|ddtj|j	t|ddS(s
        A suppression set on a module prevents warnings emitted by any test
        mewthods defined in that module which match the suppression from being
        emitted.
        iRiiN(
RRR{RtTestSuppression2ttestSuppressModuleRRRRRRRD(RR((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_suppressModulescCs|jjtjj}|j||jtjjg}|j|ddtj	|j|ddtj
|j|ddtj|jt|ddS(s
        The suppression set on a test method completely overrides a suppression
        with wider scope; if it does not match a warning emitted by that test
        method, the warning is emitted, even if a wider suppression matches.
        iRiiiN(
RR{RRttestOverrideSuppressClassRRRRRRRRD(RtcaseR((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_overrideSuppressClasss	
(RRRR RRRR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRs					tGCMixincBsdeZdZdejfdYZdejfdYZdZdZdZ	dZ
RS(	s
    I provide a few mock tests that log setUp, tearDown, test execution and
    garbage collection. I'm used to test whether gc.collect gets called.
    t	BasicTestcBs#eZdZdZdZRS(cCs|jddS(NR (t_log(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR scCs|jddS(NR%(R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_fooscCs|jddS(NttearDown(R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRs(RRR RR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRs		t	ClassTestcBseZdZdZRS(cCs|jddS(Nttest1(R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRAscCs|jddS(Nttest2(R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRB
s(RRRARB(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR
s	cCs|jj|dS(N(t_collectCalledtappend(Rtmsg((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRscCs|jddS(sFake gc.collectR.N(R(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR.scCs>g|_|j|j_|j_tj|_|jt_dS(N(RRRRR-R.t_oldCollect(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR s	cCs|jt_dS(N(RR-R.(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRs(RRR2RR)RRRR.R R(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRs			tTestGarbageCollectionDefaultcBseZdZRS(cCsH|jd}tj}|j||j|jdddgdS(sH
        By default, tests should not force garbage collection.
        RR R%RN(RRRR'RR(RR%R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_collectNotDefault$s
(RRR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR"stTestGarbageCollectioncBseZdZRS(cCs]tjd}tj|}tj}|j||j|jdddddgdS(sG
        test gc.collect is called before and after each test.
        RR.R R%RN(	RRRt _ForceGarbageCollectionDecoratorRRR'RR(RR%R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_collectCalled1s
(RRR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR/stTestUnhandledDeferredcBs,eZdZdZdZdZRS(cCs9ddlm}tjtj|jd|_dS(Ni(tweirdttest_unhandledDeferred(ttwisted.trial.testRR-tdisableRRtTestBleedingR(RR((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR As
cCs9tj}|j||jt|jdddS(so
        Forcing garbage collection should cause unhandled Deferreds to be
        reported as errors.
        is(Unhandled deferred passed without noticeN(RRRRRDR(RR((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_isReportedHs
cCsktj}|j||jtj}|j|dd|j}|jt|dddS(s
        Forcing garbage collection in the test should mean that there are
        no unreachable cycles immediately after the test completes.
        isunreachable cycle still existedsErrors logged after gc.collectN(RRRtflushLoggedErrorsR-R.RRD(RRtntx((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_doesntBleedRs

cCs"tjtj|jdS(N(R-R.tenableR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRbs

(RRR RRR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR?s		
	tTestAddCleanupcBsoeZdZdejfdYZdZdZdZdZ	dZ
dZd	Zd
Z
RS(s1
    Test the addCleanup method of TestCase.
    tMockTestcBs>eZdZdZdZdZdZdZRS(cCsdg|_dS(NR (tlog(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR pscCsdg|_tddS(NR sDeliberate failure(RR8(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pytbrokenSetUpsscCsdg|_tjddS(NR s
Don't do this(RRR6(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
skippingSetUpwscCs|jj|dS(N(RR(Rtthing((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR{scCs|jjddS(NR(RR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR~scCs|jjddS(NtrunTest(RR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRs(RRR RRRRR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRns					cCs2tjj|tj|_tj|_dS(N(	RR)R RRRRRR%(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR scCs^|jj|j_|jj|jjd|jj|j|jddg|jjdS(sQ
        Callables added with C{addCleanup} are run even if setUp fails.
        tfooR N(	R%RR t
addCleanupRR'RRR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt!test_addCleanupCalledIfSetUpFailsscCs^|jj|j_|jj|jjd|jj|j|jddg|jjdS(s
        Callables added with C{addCleanup} are run even if setUp raises
        L{SkipTest}. This allows test authors to reliably provide clean up
        code using C{addCleanup}.
        RR N(	R%RR RRR'RRR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt!test_addCleanupCalledIfSetUpSkipsscCsn|jj|jjd|jj|jjd|jj|j|jdddddg|jjdS(s~
        Callables added with C{addCleanup} should be called before C{tearDown}
        in reverse order of addition.
        RtbarR RRN(R%RRR'RRR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt#test_addCleanupCalledInReverseOrders
cswfd}jjjjdjj|djjjjdddddgjjdS(s
        If an added callable returns a L{Deferred}, then the test should wait
        until that L{Deferred} has fired before running the next cleanup
        method.
        cs5tj}tjd|j||jjjS(Ni(RtDeferredRt	callLatertcallbacktaddCallbackR%R(Rtd(R(sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pytcleanupsRRR RRN(R%RRR'RRR(RR((RsA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt test_addCleanupWaitsForDeferredsscCs|jj|jjd|jj|j|j|jj|jdt|jj	|jj	\\}}|j||j|j|j
ddS(s
        Errors raised in cleanup functions should be treated like errors in
        C{tearDown}. They should be added as errors and fail the test. Skips,
        todos and failures are all treated as errors.
        RiN(R%RR;R'RRvRRRDRtgetErrorMessage(RR%terror((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_errorInCleanupIsCapturedscCs|jj|jjd|jj|jjd|jj|j|jddddg|jj|jdt|jj	|jj	\\}}|j||j|j|j
ddS(sq
        If a cleanup raises an error then that does not stop the other
        cleanups from being run.
        RRR RRiN(R%RRR;R'RRRRDRR(RR%R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt&test_cleanupsContinueRunningAfterErrors
cCs|jj|jjd|jj|jjd|jj|j|jdddg|jj|jdt|jj|jj\\}}\}}|j||j|j||j|j|j	d|j|j	ddS(sm
        If more than one cleanup fails, then the test should fail with more
        than one error.
        RRR RRiN(
R%RR;R'RRRRDRR(RRterror1Rterror2((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_multipleErrorsReporteds
(RRR2RR)RR RRRRRRR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRis		
					tTestSuiteClearingcBs eZdZdZdZRS(sM
    Tests for our extension that allows us to clear out a L{TestSuite}.
    cCs\tj}|jtj|jd|jtj||jd|jdS(sh
        Calling L{unittest._clearSuite} on a populated L{TestSuite} removes
        all tests.
        iiN(Rt	TestSuitetaddTestR)RRt_clearSuite(RR
((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_clearSuites

cCshtd}|j}|jtj|jd|jtj||jd|jdS(s
        Calling L{unittest._clearSuite} on a populated standard library
        L{TestSuite} removes all tests.

        This test is important since C{_clearSuite} operates by mutating
        internal variables.
        RiiN(t
__import__RRRR)RRR(RtpyunitR
((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_clearPyunitSuites
(RRR2RR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRs	
tTestTestDecoratorcBsqeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
RS(s1
    Tests for our test decoration features.
    cCs|j|j|jdt|dd}t|dd}|j||||koddknr||j||ndS(sB
        Assert that the given decorated tests are equal.
        sDifferent classt
_originalTestN(RRPtgetattrR0R/(RtobservedtexpectedtobservedOriginaltexpectedOriginal((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pytassertTestsEqualscCs|j|j|jd|jt|jt|jdx^t|j|jD]G\}}t|dddk	r|j||qT|j||qTWdS(sS
        Assert that the given test suites with decorated tests are equal.
        sDifferent classsDifferent number of tests.t_testsN(	RRPRDRtzipRR0tassertSuitesEqualR(RRRtobservedTesttexpectedTest((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR(scCsHtj}tj|}t}|j||j|j|dS(s
        For decorated tests, C{run} uses a result adapter that preserves the
        test decoration for calls to C{addError}, C{startTest} and the like.

        See L{reporter._AdaptedReporter}.
        N(RR)t
TestDecoratorRR'RR%(RR%t
decoratedTestR((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_usesAdaptedReporterWithRun8s
	
cCsEtj}tj|}t}|||j|j|dS(s
        For decorated tests, C{__call__} uses a result adapter that preserves
        the test decoration for calls to C{addError}, C{startTest} and the
        like.

        See L{reporter._AdaptedReporter}.
        N(RR)RRRR%(RR%RR((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt test_usesAdaptedReporterWithCallFs
	
cCs>tj}tj|tj}|jtj||dS(s
        Calling L{decorate} on a single test case returns the test case
        decorated with the provided decorator.
        N(RR)tdecorateRR(RR%R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_decorateSingleTestUscCs\tj}tj|g}tj|tj}|j|tjtj|gdS(s
        Calling L{decorate} on a test suite will return a test suite with
        each test decorated with the provided decorator.
        N(RR)RRRR(RR%R
R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_decorateTestSuite_s
cCstj}tj|g}tj|tj}|j|tjtj|g|j|tjtj|gdS(sU
        Calling L{decorate} on a test suite will mutate the original suite.
        N(RR)RRRR(RR%R
R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt#test_decorateInPlaceMutatesOriginalkscCsttdd}|dkr0tjdntj}tj|g}||}tj|tj}||}|j	||dS(sc
        When decorating a test suite in-place, the number of references to the
        test objects in that test suite should stay the same.

        Previously, L{unittest.decorate} recreated a test suite, so the
        original suite kept references to the test objects. This test is here
        to ensure the problem doesn't reappear again.
        tgetrefcounts*getrefcount not supported on this platformN(
RtsysR0RR6R)RRRR(RRR%R
tcount1Rtcount2((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt test_decorateTestSuiteReferencesys	cCsztj}tjtj|gg}tj|tj}tjtjtj|gg}|j||dS(s
        Calling L{decorate} on a test suite with nested suites will return a
        test suite that maintains the same structure, but with all tests
        decorated.
        N(RR)RRRR(RR%R
RR((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_decorateNestedTestSuites!cCsStj}tj|tj}tj|tj}|j|tj|dS(s
        Calling L{decorate} on a test suite with already-decorated tests
        decorates all of the tests in the suite again.
        N(RR)RRR(RR%RtredecoratedTest((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_decorateDecoratedSuites		cCs\tj}tj|g}tj|tj}|j|tjtj|gdS(s
        Tests can be in non-standard suites. L{decorate} preserves the
        non-standard suites when it decorates the tests.
        N(RR)RtDestructiveTestSuiteRRR(RR%R
t	decorated((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_decoratePreservesSuites(RRR2RRRRRRRRRRR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRs	
				
					
tTestMonkeyPatchSupportcBsDeZdZdZdZdZdZdZdZRS(sF
    Tests for the patch() helper method in L{unittest.TestCase}.
    cCs1d|_d|_|j|_tj|_dS(Ntoriginaltpatched(t
originalValuetpatchedValuet
objectToPatchRR)R%(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyR s		cCs3|jj|d|j|j|j|jdS(si
        Calling C{patch()} on a test monkey patches the specified object and
        attribute.
        RN(R%tpatchRRR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt
test_patchscCsI|jj|d|j|jjtj|j|j|jdS(sw
        Any monkey patches introduced by a test using C{patch()} are reverted
        after the test has run.
        RN(	R%RRR'RRyRRR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_patchRestoredAfterRunscCs?|jj|d|j}|j|j|j|jdS(s
        C{patch()} return a L{monkey.MonkeyPatcher} object that can be used to
        restore the original values before the end of the test.
        RN(R%RRtrestoreRRR(RR((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_revertDuringTests
cCsI|jj|d|j}|j|j|j|j|jdS(sq
        The returned L{monkey.MonkeyPatcher} object can re-apply the patch
        during the test run.
        RN(R%RRRRR(RR((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_revertAndRepatchs

cCs|jj|d|j|j|j|j|jj|dd|j|jd|jjtj|j|j|jdS(sW
        Successive patches are applied and reverted just like a single patch.
        Rssecond valueN(	R%RRRRR'RRyR(R((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_successivePatchess(	RRR2R R	R
RR
R(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRs				
	
	tTestIterateTestscBs2eZdZdZdZdZdZRS(s]
    L{_iterateTests} returns a list of all test cases in a test suite or test
    case.
    cCs2tj}|j|gttj|dS(sj
        L{_iterateTests} on a single test case returns a list containing that
        test case.
        N(RR)Rtlistt
_iterateTests(RR%((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_iterateTestCasescCsDtj}tj|g}|j|gttj|dS(s
        L{_iterateTests} on a test suite that contains a single test case
        returns a list containing that test case.
        N(RR)RRRRR(RR%R
((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_iterateSingletonTestSuitescCsPtj}tjtj|gg}|j|gttj|dS(sP
        L{_iterateTests} returns tests that are in nested test suites.
        N(RR)RRRRR(RR%R
((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyttest_iterateNestedTestSuitescCsVtj}tjtj|g|g}|j||gttj|dS(sU
        L{_iterateTests} returns tests in left-to-right, depth-first order.
        N(RR)RRRRR(RR%R
((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt#test_iterateIsLeftToRightDepthFirsts!(RRR2RRRR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyRs
			
		(((&R2R-RzRR+ttwisted.internetRRt
twisted.trialRRRRRRRt twisted.trial.test.test_reporterRR	R)RR3RLRXRfRjRxRRRRRRRRRRR(((sA/usr/lib/python2.7/dist-packages/twisted/trial/test/test_tests.pyt<module>s00":5>,,=& Q&
*%B