Your IP : 172.28.240.42


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


=Nc@sdZeZddlZddlZddlZddlmZddlm	Z	m
Z
ddlmZddl
mZdefdYZd	eefd
YZdefdYZejejejejdS(
s/
Tests for implementations of L{IReactorCore}.
iN(tFileDescriptor(tReactorAlreadyRunningtReactorNotRestartable(tDeferred(tReactorBuildertObjectModelIntegrationMixincBseZdZdZRS(sN
    Helpers for tests about the object model of reactor-related objects.
    cCsZ|j|ttjt|}x.|D]&}|jt|td|fq,WdS(s.
        Assert that the given object is an instance of a new-style class and
        that there are no classic classes in the inheritance hierarchy of
        that class.

        This is a beneficial condition because PyPy is better able to
        optimize attribute lookup on such classes.
        s%r is not new-styleN(tassertIsInstancetobjecttinspecttgetmrottypet
assertTruet
issubclass(tselftinstancetmrotsubclass((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pytassertFullyNewStyles	
(t__name__t
__module__t__doc__R(((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyRstObjectModelIntegrationTestcBseZdZdZRS(sH
    Test details of object model integration against all reactors.
    cCs|j}|j|dS(s
        Checks that all reactors on a platform have method resolution order
        containing only new style classes.
        N(tbuildReactorR(R
treactor((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyttest_newstyleReactor/s(RRRR(((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyR*stSystemEventTestsBuildercBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZRS(s{
    Builder defining tests relating to L{IReactorCore.addSystemEventTrigger}
    and L{IReactorCore.fireSystemEvent}.
    cCs#|j}|jt|jdS(su
        C{reactor.stop()} raises L{RuntimeError} when called when the reactor
        has not been started.
        N(RtassertRaisestRuntimeErrortstop(R
R((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyttest_stopWhenNotStarted>scCs@|j}|j|j|j||jt|jdS(sr
        C{reactor.stop()} raises L{RuntimeError} when called after the reactor
        has been stopped.
        N(RtcallWhenRunningRt
runReactorRR(R
R((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyttest_stopWhenAlreadyStoppedGs
cCso|j}g}|j|jd|j|jd|j|j|j||j|ddgdS(sm
        Functions are run in the order that they were passed to
        L{reactor.callWhenRunning}.
        tfirsttsecondN(RRtappendRRtassertEqual(R
Rtevents((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyttest_callWhenRunningOrderRs
cs|jifd}fd}fd}jdd|jdd|jdd|jj|ji|j|jitd6td6td6dS(	s
        The reactor is not running when C{"before"} C{"startup"} triggers are
        called and is running when C{"during"} and C{"after"} C{"startup"}
        triggers are called.
        csjd<dS(Ntbefore(trunning((tstateR(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyt
beforeStartuphscsjd<dS(Ntduring(R(((R)R(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyt
duringStartupjscsjd<dS(Ntafter(R(((R)R(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pytafterStartuplsR'tstartupR+R-N(RtaddSystemEventTriggerRRR$RtFalsetTrue(R
R*R,R.((RR)sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyttest_runningForStartupEvents`s 

cs|j}d	gfd}fd}|jdd||jdd|d	gfd}|jtd||j|j|jdd	|jdd	|j||jdd|jddd	S(
se
        Signal handlers are installed in responsed to the C{"during"}
        C{"startup"}.
        csdd<dS(NR'i(((tphase(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyR*scsdd<dS(NR-i(((R4(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyR.sR'R/R-csdd<dS(Ni((tsignumtaction(tsawPhaseR4(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyt
fakeSignalstsignaliN(	RtNoneR0tpatchR9RRR$R(R
RR*R.R8((R7R4sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyt)test_signalHandlersInstalledDuringStartup{s		
cs|j}g|jddfd|jddfd|jddfd|j|j|j||jd	d
dgdS(s
        C{reactor.stop()} fires all three phases of shutdown event triggers
        before it makes C{reactor.run()} return.
        R'tshutdowncs
jdS(NR'R=(sbeforeR=(R#((R%(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyt<lambda>sR+cs
jdS(NR+R=(sduringsshutdown(R#((R%(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyR>sR-cs
jdS(NR-R=(saftersshutdown(R#((R%(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyR>sN(sbeforesshutdown(sduringsshutdown(saftersshutdown(RR0RRRR$(R
R((R%sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyttest_stopShutDownEventss 
cs|jgjddjdfd}j||jg|j|jddgdS(sl
        C{"before"} C{"shutdown"} triggers are not run synchronously from
        L{reactor.stop}.
        R'R=sbefore shutdowncsjjddS(Ntstopped(RR#((RR%(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pytstopIts
R@N(RR0R#RR$R(R
RA((RR%sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyt(test_shutdownFiresTriggersAsynchronouslys

cstgdtfdY}dtffdY}|j}t||gfd|_|j|j|j||jt	|j
td|jddS(	s
        A L{IFileDescriptor.connectionLost} implementation which raises an
        exception does not prevent the remaining L{IFileDescriptor}s from
        having their C{connectionLost} method called.
        tProblematicFileDescriptorcBseZdZRS(cSstddS(Nssimulated connectionLost error(R(R
treason((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pytconnectionLosts(RRRE(((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyRCstOKFileDescriptorcseZfdZRS(cstd<dS(Ni(R2(R
RD(tlostOK(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyREs(RRRE((RG(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyRFscsS(N(((tfds(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyR>siiN(
R1RRtitert	removeAllRRRR$tlentflushLoggedErrorsRR(R
RCRFR((RHRGsC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyttest_shutdownDisconnectsCleanlys	
cshgfd}jj|jjjjdgdS(s{
        C{reactor.run()} raises L{ReactorAlreadyRunning} when called when
        the reactor is already running.
        cs$jtjjddS(Nttested(RRtrunR#((R
RR%(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pytreentrantRunsRNN(RRRRR$(R
RP((R
R%RsC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyttest_multipleRuns

cssgfd}fd|jjdd||j|jddgdS(s
        When there is a C{'before'} C{'startup'} trigger which returns an
        unfired L{Deferred}, C{reactor.run()} starts the reactor and does not
        return until after C{reactor.stop()} is called
        cs=jdt}|jjd|jd|S(Nttriggeri(R#RtaddCallbackt	callLatertcallbackR:(td(RRUR%(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyRRs

	
csjdjdS(NRU(R#R(tignored(R%R(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyRUs
R'R/RRRUN(RR0RR$(R
RR((RUR%RsC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyt,test_runWithAsynchronousBeforeStartupTriggers
cCsk|j}|jd|j}tj}|jdtj|}|j|dk|jdS(s6
        C{reactor.iterate()} does not block.
        iiiN(RRTtcrashttimetiteratet
failUnlesstcancel(R
Rtttstarttelapsed((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyttest_iterates
csx|j}g|jddfd|j|jd|j|j||j|j|jddS(sc
        C{reactor.crash()} stops the reactor and does not fire shutdown
        triggers.
        R'R=cs
jdS(NR'R=(sbeforesshutdown(R#((R%(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyR>sis8Shutdown triggers invoked but they should not have been.N(RR0RRTRYRtassertFalseR((R
R((R%sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyt
test_crashs
csgfd}|jj||jfd}j||j|jddtfgdS(sp
        C{reactor.run()} restarts the reactor after it has been stopped by
        C{reactor.crash()}.
        csjdjdS(NRY(R#RY((R%R(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyRY+s
cs$jdjfjdS(NR(R#R(R((R%R(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyR1sRYRN(RRRR$R2(R
RYR((RR%sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyttest_runAfterCrash%s



csngfd}jjjjdd|jjdgdS(s
        C{reactor.run()} raises L{ReactorNotRestartable} when called when
        the reactor is being run after getting stopped priorly.
        cs$jtjjddS(NRN(RRROR#((R%R
R(sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pytrestart?sR-R=RNN(RRRR0RR$(R
Re((R
R%RsC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyttest_runAfterStop9s
(RRRRR R&R3R<R?RBRMRQRXRaRcRdRf(((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyR9s									 					(RR
t
__metaclass__R9RZRttwisted.internet.abstractRttwisted.internet.errorRRttwisted.internet.deferRt#twisted.internet.test.reactormixinsRRRRRtglobalstupdatetmakeTestCaseClasses(((sC/usr/lib/python2.7/dist-packages/twisted/internet/test/test_core.pyt<module>s