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_sigchld.pyc


[XMc@sdZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZddl
m
Z
mZddl
mZmZmZd	dd
YZdeefdYZd
eefdYZdeefdYZdeefdYZdS(sX
Tests for L{twisted.internet._sigchld}, an alternate, superior SIGCHLD
monitoring API.
iN(tmsg(tTestCase(tsetNonBlocking(tinstallHandlertisDefaultHandler(t_extInstallHandlert_extIsDefaultHandler(t_installHandlerUsingSetWakeupt_installHandlerUsingSignalt_isDefaultHandlertSIGCHLDTestsMixincBseZdZeedddkr-dZndZdZdZ	dZ
dZdZd	Z
d
ZdZRS(
s
    Mixin for L{TestCase} subclasses which defines several tests for
    I{installHandler} and I{isDefaultHandler}.  Subclasses are expected to
    define C{self.installHandler} and C{self.isDefaultHandler} to invoke the
    implementation to be tested.
    tSIGCHLDsPlatform does not have SIGCHLDcCs
tdS(s
        Override in a subclass to install a SIGCHLD handler which writes a byte
        to the given file descriptor.  Return the previously registered file
        descriptor.
        N(tNotImplementedError(tselftfd((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyRscCs
tdS(s
        Override in a subclass to determine if the current SIGCHLD handler is
        SIG_DFL or not.  Return True if it is SIG_DFL, False otherwise.
        N(R(R
((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyR(scCsVtj\}}|jtj||jtj|t|t|||fS(sk
        Create a non-blocking pipe which will be closed after the currently
        running test.
        (tostpipet
addCleanuptcloseR(R
treadtwrite((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyR0s

cCstjtj}|tjkrC||_tjtjtjn	d|_|jd|_|jdk	r|jdkrtd|j|jft	dndS(s
        Save the current SIGCHLD handler as reported by L{signal.signal} and
        the current file descriptor registered with L{installHandler}.
        isSIGCHLD setup issue: %r %rs,You used some signal APIs wrong!  Try again.N(
tsignalt	getsignalRtSIG_DFLtsignalModuleHandlertNoneRtoldFDRtRuntimeError(R
thandler((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pytsetUp=s		cCsq|jdtjtjtj|jdk	rKtjtj|jn"|jdkrm|j|jndS(sM
        Restore whatever signal handler was present when setUp ran.
        iN(RRRRRRR(R
((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyttearDownPs
cCs|j|jtjtjtj|j|jtjtjtj|j|jtjtjd|j|jdS(sn
        L{isDefaultHandler} returns true if the SIGCHLD handler is SIG_DFL,
        false otherwise.
        cWsdS(N(R(targs((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyt<lambda>isN(t
assertTrueRRRtSIG_IGNtassertFalseR(R
((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyttest_isDefaultHandler_scCs>|j\}}|j|}|j|j||dS(sV
        L{installHandler} returns the previously registered file descriptor.
        N(RRtassertEqual(R
RRR((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyttest_returnOldFDmscCsi|j\}}|j|j|j||j|j|jd|j|jdS(sO
        C{installHandler(-1)} removes the SIGCHLD handler completely.
        iN(RR!RRR#(R
RR((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyttest_uninstallHandlervs

cCs|j\}}|j||jttj|d}|j|jtjtj	tj
tj|jt
tj|dddS(s
        The file descriptor passed to L{installHandler} has a byte written to
        it when SIGCHLD is delivered to the process.
        iiN(RRtassertRaisestOSErrorRRR%terrnotEAGAINtkilltgetpidRRtlen(R
RRtexc((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyttest_installHandlers
N(t__name__t
__module__t__doc__tgetattrRRtskipRRRRRR$R&R'R0(((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyR
s					
						tDefaultSIGCHLDTestscBs&eZdZeeZeeZRS(ss
    Tests for whatever implementation is selected for the L{installHandler}
    and L{isDefaultHandler} APIs.
    (R1R2R3tstaticmethodRR(((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyR6stExtensionSIGCHLDTestscBsDeZdZyddlZWnek
r5dZnXeZe	Z
RS(s~
    Tests for the L{twisted.internet._sigchld} implementation of the
    L{installHandler} and L{isDefaultHandler} APIs.
    iNs*twisted.internet._sigchld is not available(R1R2R3ttwisted.internet._sigchldttwistedtImportErrorR5RRRR(((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyR8s

tSetWakeupSIGCHLDTestscBs_eZdZeedddks<eedddkrEdZneeZ	ee
ZRS(sy
    Tests for the L{signal.set_wakeup_fd} implementation of the
    L{installHandler} and L{isDefaultHandler} APIs.
    t
set_wakeup_fdtsiginterrupts%signal.set_wakeup_fd is not availableN(R1R2R3R4RRR5R7RRR	R(((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyR<s	tPlainSignalModuleSIGCHLDTestscBs&eZdZeeZeeZRS(sr
    Tests for the L{signal.signal} implementation of the L{installHandler}
    and L{isDefaultHandler} APIs.
    (R1R2R3R7RRR	R(((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyR?s((R3RRR*ttwisted.python.logRttwisted.trial.unittestRttwisted.internet.fdescRttwisted.internet._signalsRRRRRRR	R
R6R8R<R?(((sF/usr/lib/python2.7/dist-packages/twisted/internet/test/test_sigchld.pyt<module>s$