/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_time.py (3758B)
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Tests for implementations of L{IReactorTime}. """ from twisted.internet.interfaces import IReactorThreads, IReactorTime from twisted.internet.test.reactormixins import ReactorBuilder from twisted.python.log import msg from twisted.python.runtime import platform from twisted.trial.unittest import SkipTest class TimeTestsBuilder(ReactorBuilder): """ Builder for defining tests relating to L{IReactorTime}. """ requiredInterfaces = (IReactorTime,) def test_delayedCallStopsReactor(self): """ The reactor can be stopped by a delayed call. """ reactor = self.buildReactor() reactor.callLater(0, reactor.stop) reactor.run() def test_distantDelayedCall(self): """ Scheduling a delayed call at a point in the extreme future does not prevent normal reactor operation. """ reactor = self.buildReactor() if IReactorThreads.providedBy(reactor): def eventSource(reactor, event): msg( format="Thread-based event-source scheduling %(event)r", event=event ) reactor.callFromThread(event) else: raise SkipTest( "Do not know how to synthesize non-time event to " "stop the test" ) # Pick a pretty big delay. delayedCall = reactor.callLater(2 ** 128 + 1, lambda: None) def stop(): msg("Stopping the reactor") reactor.stop() # Use repeated invocation of the event source to set up the call to stop # the reactor. This makes it more likely at least one normal iteration # will take place with the delayed call in place before the slightly # different reactor shutdown logic alters things. eventSource(reactor, lambda: eventSource(reactor, stop)) # Run the reactor directly, without a timeout. A timeout would # interfere with the purpose of this test, which is to have the timeout # passed to the reactor's doIterate implementation (potentially) be # very, very large. Hopefully the event source defined above will work # and cause the reactor to stop. reactor.run() # The reactor almost surely stopped before the delayed call # fired... right? self.assertTrue(delayedCall.active()) self.assertIn(delayedCall, reactor.getDelayedCalls()) class GlibTimeTestsBuilder(ReactorBuilder): """ Builder for defining tests relating to L{IReactorTime} for reactors based off glib. """ requiredInterfaces = (IReactorTime,) if platform.isWindows(): _reactors = ["twisted.internet.gtk2reactor.PortableGtkReactor"] else: _reactors = [ "twisted.internet.glib2reactor.Glib2Reactor", "twisted.internet.gtk2reactor.Gtk2Reactor", ] def test_timeout_add(self): """ A L{reactor.callLater} call scheduled from a C{gobject.timeout_add} call is run on time. """ import gobject # type: ignore[import] reactor = self.buildReactor() result = [] def gschedule(): reactor.callLater(0, callback) return 0 def callback(): result.append(True) reactor.stop() reactor.callWhenRunning(gobject.timeout_add, 10, gschedule) self.runReactor(reactor, 5) self.assertEqual(result, [True]) globals().update(TimeTestsBuilder.makeTestCaseClasses()) globals().update(GlibTimeTestsBuilder.makeTestCaseClasses())