/usr/lib/python3/dist-packages/twisted/internet/test
NameSizeModeActions
fake_CAs/-0755rm
__pycache__/-0755rm
connectionmixins.py201840644editdlrm
fakeendpoint.py16630644editdlrm
modulehelpers.py16720644editdlrm
process_cli.py5470644editdlrm
process_connectionlost.py1260644editdlrm
process_gireactornocompat.py8160644editdlrm
process_helper.py12820644editdlrm
reactormixins.py146090644editdlrm
test_abstract.py19760644editdlrm
test_address.py82660644editdlrm
test_asyncioreactor.py93270644editdlrm
test_base.py136840644editdlrm
test_baseprocess.py25880644editdlrm
test_core.py111250644editdlrm
test_default.py34190644editdlrm
test_defer_await.py65140644editdlrm
test_defer_yieldfrom.py48480644editdlrm
test_endpoints.py1487200644editdlrm
test_epollreactor.py73220644editdlrm
test_error.py10900644editdlrm
test_fdset.py134970644editdlrm
test_filedescriptor.py27610644editdlrm
test_gireactor.py65160644editdlrm
test_glibbase.py22170644editdlrm
test_inlinecb.py114820644editdlrm
test_inotify.py185620644editdlrm
test_iocp.py77000644editdlrm
test_kqueuereactor.py18530644editdlrm
test_main.py13310644editdlrm
test_newtls.py65320644editdlrm
test_pollingfile.py12970644editdlrm
test_posixbase.py97180644editdlrm
test_posixprocess.py112030644editdlrm
test_process.py367320644editdlrm
test_protocol.py185200644editdlrm
test_resolver.py196100644editdlrm
test_serialport.py19880644editdlrm
test_sigchld.py39220644editdlrm
test_socket.py94430644editdlrm
test_stdio.py65970644editdlrm
test_tcp.py1066210644editdlrm
test_testing.py162390644editdlrm
test_threads.py87340644editdlrm
test_time.py37580644editdlrm
test_tls.py133490644editdlrm
test_udp.py168810644editdlrm
test_udp_internals.py48370644editdlrm
test_unix.py348540644editdlrm
test_win32events.py64730644editdlrm
test_win32serialport.py53300644editdlrm
_posixifaces.py43910644editdlrm
_win32ifaces.py39750644editdlrm
__init__.py1120644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/internet/test/test_sigchld.py (3922B)
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Tests for L{twisted.internet._sigchld}, an alternate, superior SIGCHLD monitoring API. """ import errno import os import signal from twisted.python.log import msg from twisted.python.runtime import platformType from twisted.trial.unittest import SynchronousTestCase if platformType == "posix": from twisted.internet._signals import installHandler, isDefaultHandler from twisted.internet.fdesc import setNonBlocking else: skip = "These tests can only run on POSIX platforms." class SetWakeupSIGCHLDTests(SynchronousTestCase): """ Tests for the L{signal.set_wakeup_fd} implementation of the L{installHandler} and L{isDefaultHandler} APIs. """ def pipe(self): """ Create a non-blocking pipe which will be closed after the currently running test. """ read, write = os.pipe() self.addCleanup(os.close, read) self.addCleanup(os.close, write) setNonBlocking(read) setNonBlocking(write) return read, write def setUp(self): """ Save the current SIGCHLD handler as reported by L{signal.signal} and the current file descriptor registered with L{installHandler}. """ handler = signal.getsignal(signal.SIGCHLD) if handler != signal.SIG_DFL: self.signalModuleHandler = handler signal.signal(signal.SIGCHLD, signal.SIG_DFL) else: self.signalModuleHandler = None self.oldFD = installHandler(-1) if self.signalModuleHandler is not None and self.oldFD != -1: msg( "Previous test didn't clean up after its SIGCHLD setup: %r %r" % (self.signalModuleHandler, self.oldFD) ) def tearDown(self): """ Restore whatever signal handler was present when setUp ran. """ # If tests set up any kind of handlers, clear them out. installHandler(-1) signal.signal(signal.SIGCHLD, signal.SIG_DFL) # Now restore whatever the setup was before the test ran. if self.signalModuleHandler is not None: signal.signal(signal.SIGCHLD, self.signalModuleHandler) elif self.oldFD != -1: installHandler(self.oldFD) def test_isDefaultHandler(self): """ L{isDefaultHandler} returns true if the SIGCHLD handler is SIG_DFL, false otherwise. """ self.assertTrue(isDefaultHandler()) signal.signal(signal.SIGCHLD, signal.SIG_IGN) self.assertFalse(isDefaultHandler()) signal.signal(signal.SIGCHLD, signal.SIG_DFL) self.assertTrue(isDefaultHandler()) signal.signal(signal.SIGCHLD, lambda *args: None) self.assertFalse(isDefaultHandler()) def test_returnOldFD(self): """ L{installHandler} returns the previously registered file descriptor. """ read, write = self.pipe() oldFD = installHandler(write) self.assertEqual(installHandler(oldFD), write) def test_uninstallHandler(self): """ C{installHandler(-1)} removes the SIGCHLD handler completely. """ read, write = self.pipe() self.assertTrue(isDefaultHandler()) installHandler(write) self.assertFalse(isDefaultHandler()) installHandler(-1) self.assertTrue(isDefaultHandler()) def test_installHandler(self): """ The file descriptor passed to L{installHandler} has a byte written to it when SIGCHLD is delivered to the process. """ read, write = self.pipe() installHandler(write) exc = self.assertRaises(OSError, os.read, read, 1) self.assertEqual(exc.errno, errno.EAGAIN) os.kill(os.getpid(), signal.SIGCHLD) self.assertEqual(len(os.read(read, 5)), 1)