/usr/lib/python3/dist-packages/twisted/internet/test/__pycache__
NameSizeModeActions
connectionmixins.cpython-310.pyc244520644editdlrm
fakeendpoint.cpython-310.pyc23820644editdlrm
modulehelpers.cpython-310.pyc19920644editdlrm
process_cli.cpython-310.pyc4870644editdlrm
process_connectionlost.cpython-310.pyc2900644editdlrm
process_gireactornocompat.cpython-310.pyc7270644editdlrm
process_helper.cpython-310.pyc11080644editdlrm
reactormixins.cpython-310.pyc118080644editdlrm
test_abstract.cpython-310.pyc23500644editdlrm
test_address.cpython-310.pyc93620644editdlrm
test_asyncioreactor.cpython-310.pyc86650644editdlrm
test_base.cpython-310.pyc153310644editdlrm
test_baseprocess.cpython-310.pyc29270644editdlrm
test_core.cpython-310.pyc124370644editdlrm
test_default.cpython-310.pyc41100644editdlrm
test_defer_await.cpython-310.pyc77830644editdlrm
test_defer_yieldfrom.cpython-310.pyc52920644editdlrm
test_endpoints.cpython-310.pyc1363780644editdlrm
test_epollreactor.cpython-310.pyc72010644editdlrm
test_error.cpython-310.pyc13490644editdlrm
test_fdset.cpython-310.pyc144020644editdlrm
test_filedescriptor.cpython-310.pyc37560644editdlrm
test_gireactor.cpython-310.pyc62420644editdlrm
test_glibbase.cpython-310.pyc24910644editdlrm
test_inlinecb.cpython-310.pyc144480644editdlrm
test_inotify.cpython-310.pyc193070644editdlrm
test_iocp.cpython-310.pyc76750644editdlrm
test_kqueuereactor.cpython-310.pyc24880644editdlrm
test_main.cpython-310.pyc18240644editdlrm
test_newtls.cpython-310.pyc72350644editdlrm
test_pollingfile.cpython-310.pyc18970644editdlrm
test_posixbase.cpython-310.pyc129550644editdlrm
test_posixprocess.cpython-310.pyc112530644editdlrm
test_process.cpython-310.pyc367530644editdlrm
test_protocol.cpython-310.pyc199720644editdlrm
test_resolver.cpython-310.pyc202720644editdlrm
test_serialport.cpython-310.pyc30250644editdlrm
test_sigchld.cpython-310.pyc40040644editdlrm
test_socket.cpython-310.pyc91490644editdlrm
test_stdio.cpython-310.pyc58450644editdlrm
test_tcp.cpython-310.pyc1128600644editdlrm
test_testing.cpython-310.pyc169500644editdlrm
test_threads.cpython-310.pyc80180644editdlrm
test_time.cpython-310.pyc38710644editdlrm
test_tls.cpython-310.pyc143900644editdlrm
test_udp.cpython-310.pyc177310644editdlrm
test_udp_internals.cpython-310.pyc49530644editdlrm
test_unix.cpython-310.pyc355390644editdlrm
test_win32events.cpython-310.pyc70730644editdlrm
test_win32serialport.cpython-310.pyc63830644editdlrm
_posixifaces.cpython-310.pyc43920644editdlrm
_win32ifaces.cpython-310.pyc26640644editdlrm
__init__.cpython-310.pyc2010644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/reactormixins.cpython-310.pyc (11808B)
o b9@sdZgdZddlZddlZddlZddlmZmZmZm Z m Z ddl m Z ddl mZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZmZzdd lmZ Wn e!ygdZYnwe ZGddde"Z#ddZ$dddZ%GdddZ&dS)a Utilities for unit testing reactor implementations. The main feature of this module is L{ReactorBuilder}, a base class for use when writing interface/blackbox tests for reactor implementations. Test case classes for reactor features should subclass L{ReactorBuilder} instead of L{SynchronousTestCase}. All of the features of L{SynchronousTestCase} will be available. Additionally, the tests will automatically be applied to all available reactor implementations. )TestTimeoutErrorReactorBuilderneedsRunningReactorN)DictOptionalSequenceTypeUnion) Interfacelog)_fullyQualifiedName)Failure)namedAny)platform)SkipTestSynchronousTestCase)DEFAULT_TIMEOUT_DURATIONacquireAttribute)processc@seZdZdZdS)rzm The reactor was still running after the timeout period elapsed in L{ReactorBuilder.runReactor}. N)__name__ __module__ __qualname____doc__rrE/usr/lib/python3/dist-packages/twisted/internet/test/reactormixins.pyr*srcCs||dS)a* Various functions within these tests need an already-running reactor at some point. They need to stop the reactor when the test has completed, and that means calling reactor.stop(). However, reactor.stop() raises an exception if the reactor isn't already running, so if the L{Deferred} that a particular API under test returns fires synchronously (as especially an endpoint's C{connect()} method may do, if the connect is to a local interface address) then the test won't be able to stop the reactor being tested and finish. So this calls C{thunk} only once C{reactor} is running. (This is just an alias for L{twisted.internet.interfaces.IReactorCore.callWhenRunning} on the given reactor parameter, in order to centrally reference the above paragraph and repeating it everywhere as a comment.) @param reactor: the L{twisted.internet.interfaces.IReactorCore} under test @param thunk: a 0-argument callable, which eventually finishes the test in question, probably in a L{Deferred} callback. N)callWhenRunning)reactorthunkrrrr1srcsD|dur ddlm}dgfdd}||||j|dS)a Stop the reactor as soon as any error is logged on the given publisher. This is beneficial for tests which will wait for a L{Deferred} to fire before completing (by passing or failing). Certain implementation bugs may prevent the L{Deferred} from firing with any result at all (consider a protocol's {dataReceived} method that raises an exception: this exception is logged but it won't ever cause a L{Deferred} to fire). In that case the test would have to complete by timing out which is a much less desirable outcome than completing as soon as the unexpected error is encountered. @param case: A L{SynchronousTestCase} to use to clean up the necessary log observer when the test is over. @param reactor: The reactor to stop. @param publisher: A L{LogPublisher} to watch for errors. If L{None}, the global log publisher will be watched. Nrr cs*r|drdSdSdS)NisError)getpopstop)eventrrunningrr stopIfError_s z stopOnError..stopIfError)twisted.pythonr addObserver addCleanupremoveObserver)caser publisherr&rr$r stopOnErrorIs   r-c @seZdZUdZdgZeregdn'egdede r,edneddge s=ed gd Z d Z d Z eeeeed <iZeeefed <d dZddZddZddZddZdddZededdeeeedeefffddZd S)ra L{SynchronousTestCase} mixin which provides a reactor-creation API. This mixin defines C{setUp} and C{tearDown}, so mix it in before L{SynchronousTestCase} or call its methods from the overridden ones in the subclass. @cvar skippedReactors: A dict mapping FQPN strings of reactors for which the tests defined by this class will be skipped to strings giving the skip message. @cvar requiredInterfaces: A C{list} of interfaces which the reactor must provide or these tests will be skipped. The default, L{None}, means that no interfaces are required. @ivar reactorFactory: A no-argument callable which returns the reactor to use for testing. @ivar originalHandler: The SIGCHLD handler which was installed when setUp ran and which will be re-installed when tearDown runs. @ivar _reactors: A list of FQPN strings giving the reactors for which L{SynchronousTestCase}s will be created. z,twisted.internet.selectreactor.SelectReactor)z/twisted.internet.gtk2reactor.PortableGtkReactorz,twisted.internet.gireactor.PortableGIReactorz0twisted.internet.gtk3reactor.PortableGtk3Reactorz/twisted.internet.win32eventreactor.Win32Reactorz0twisted.internet.iocpreactor.reactor.IOCPReactor)z*twisted.internet.glib2reactor.Glib2Reactorz(twisted.internet.gtk2reactor.Gtk2Reactorz$twisted.internet.gireactor.GIReactorz(twisted.internet.gtk3reactor.Gtk3Reactorz6twisted.internet.asyncioreactor.AsyncioSelectorReactorz$twisted.internet.cfreactor.CFReactorz(twisted.internet.pollreactor.PollReactorz*twisted.internet.epollreactor.EPollReactorz(twisted.internet.kqreactor.KQueueReactorNrequiredInterfacesskippedReactorscCs"tsttjtj|_dSdS)z Clear the SIGCHLD handler, if there is one, to ensure an environment like the one which exists prior to a call to L{reactor.run}. N)r isWindowssignalSIGCHLDSIG_DFLoriginalHandlerselfrrrsetUpszReactorBuilder.setUpcCs|jdur ttj|jtdurLt}tjrNtdtjftt dt|dkrGtjD] }t |tj q5t dtjftjsdSdSdS)z| Restore the original SIGCHLD handler and reap processes as long as there seem to be any remaining. Nz1ReactorBuilder.tearDown reaping some processes %rgMbP?<z/Timeout waiting for child processes to exit: %r)r4r1r2rtimereapProcessHandlersr msgreapAllProcessessleeposkillSIGKILL Exception)r6beginpidrrrtearDowns.    zReactorBuilder.tearDowncCsh|t|dddur!|jD] }|||dq|j||}|D]}|q+dS)z Clean up any resources which may have been allocated for the given reactor by its creation or by a test which used it. _internalReadersN) _uninstallHandlergetattrrE removeReaderconnectionLostclear disconnectAllgetDelayedCallscancel)r6rreadercallscrrrunbuildReactors     zReactorBuilder.unbuildReactorcszddlm}ddlm}Wn tyYnwt||r&|j|ur&tdz|WntyDt dd| tt w|jdurnfdd|jD}|rn|td tjd d d|Df||jS) zK Create and return a reactor using C{self.reactorFactory}. rr) CFReactorzuCFReactor uses APIs which manipulate global state, so it's not safe to run its own reactor-builder tests under itselfNzFailed to install reactorcsg|] }|s|qSr) providedBy).0requiredrRrr s z/ReactorBuilder.buildReactor..z%s does not provide %s,cSsg|]}t|qSr)fullyQualifiedName)rUxrrrrW&s)twisted.internetrtwisted.internet.cfreactorrS ImportError isinstancereactorFactoryr BaseExceptionr errflushLoggedErrorsrgetErrorMessager.rQrY __class__joinr))r6 globalReactorrSmissingrrRr buildReactorsD        zReactorBuilder.buildReactorcCst|jdtS)z Determine how long to run the test before considering it failed. @return: A C{int} or C{float} giving a number of seconds. timeout)r_parentsrr5rrr getTimeout,szReactorBuilder.getTimeoutcsV|dur|}gfdd}||}r%td|d|dS)a Run the reactor for at most the given amount of time. @param reactor: The reactor to run. @type timeout: C{int} or C{float} @param timeout: The maximum amount of time, specified in seconds, to allow the reactor to run. If the reactor is still running after this much time has elapsed, it will be stopped and an exception raised. If L{None}, the default test method timeout imposed by Trial will be used. This depends on the L{IReactorTime} implementation of C{reactor} for correct operation. @raise TestTimeoutError: If the reactor is still running after C{timeout} seconds. NcsddSN)appendr"rrtimedOutrrr"Js  z'ReactorBuilder.runReactor..stopzreactor still running after z seconds)rk callLaterrunrrM)r6rrir" timedOutCallrrnr runReactor4s  zReactorBuilder.runReactorclsreturncsi}jD]:dd}jd|ddd}Gfdddt}||_djdd|g|_|||j<q|S)z Create a L{SynchronousTestCase} subclass which mixes in C{cls} for each known reactor and return a dict mapping their names to them. .Tests_csPeZdZjZjvrjZzeZWdSey'e ZYdSw)z4ReactorBuilder.makeTestCaseClasses..testcaseN) rrrr/skiprr_r`rrcrrtrrrtestcaseds   r|r) _reactorssplitrreplacerrer)rtclassesshortReactorNamenamer|rr{rmakeTestCaseClassesUs    z"ReactorBuilder.makeTestCaseClassesrl) rrrrr}rr0extendrmisMacOSXisLinuxr_r4r.rrrr __annotations__r/rstrr7rDrQrhrkrs classmethodr rrrrrrrhsP    2 !rrl)'r__all__r>r1r9typingrrrrr zope.interfacer r'r twisted.python.deprecater rYtwisted.python.failurertwisted.python.reflectrtwisted.python.runtimertwisted.trial.unittestrrtwisted.trial.utilrrr[r_processr]rArrr-rrrrrs0