Current Path : /usr/lib/python2.7/dist-packages/twisted/internet/test/ |
Current File : //usr/lib/python2.7/dist-packages/twisted/internet/test/reactormixins.pyc |
ZOc @ s d Z e Z d d l Z d d l m Z d d l m Z m Z d d l m Z d d l m Z m Z d d l m Z d d l m Z e j r d Z n d d l m Z d d d YZ d g Z d S( s/ Tests for implementations of L{IReactorTime}. iN( t TimeoutError( t TestCaset SkipTest( t platform( t namedAnyt fullyQualifiedName( t log( t Failure( t processt ReactorBuilderc B s e Z d Z d g Z e j r@ e j d d d d d g nK e j d d d d g e j ru e j d n e j d d d g d Z d Z d Z i Z d Z d Z d Z d Z d d Z d Z e e Z RS( s L{TestCase} mixin which provides a reactor-creation API. This mixin defines C{setUp} and C{tearDown}, so mix it in before L{TestCase} 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, C{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 TestCases will be created. s, twisted.internet.selectreactor.SelectReactors, twisted.internet.gireactor.PortableGIReactors0 twisted.internet.gtk3reactor.PortableGtk3Reactors/ twisted.internet.gtk2reactor.PortableGtkReactors/ twisted.internet.win32eventreactor.Win32Reactors0 twisted.internet.iocpreactor.reactor.IOCPReactors$ twisted.internet.gireactor.GIReactors( twisted.internet.gtk3reactor.Gtk3Reactors* twisted.internet.glib2reactor.Glib2Reactors( twisted.internet.gtk2reactor.Gtk2Reactors$ twisted.internet.cfreactor.CFReactors( twisted.internet.pollreactor.PollReactors* twisted.internet.epollreactor.EPollReactors( twisted.internet.kqreactor.KQueueReactorc C s. t j s* t j t j t j | _ n d S( s 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 t isWindowst signalt SIGCHLDt SIG_DFLt originalHandler( t self( ( sG /usr/lib/python2.7/dist-packages/twisted/internet/test/reactormixins.pyt setUpU s c C sl | j d k r( t j t j | j n t d k rh x1 t j rd t j d t j f t j q7 Wn d S( s| Restore the original SIGCHLD handler and reap processes as long as there seem to be any remaining. s1 ReactorBuilder.tearDown reaping some processes %rN( R t NoneR R R t reapProcessHandlersR t msgt reapAllProcesses( R ( ( sG /usr/lib/python2.7/dist-packages/twisted/internet/test/reactormixins.pyt tearDown^ s c C s | j t | d d d k r` x+ | j D] } | j | | j d q, W| j j n | j | j } x | D] } | j q} Wd S( s Clean up any resources which may have been allocated for the given reactor by its creation or by a test which used it. t _internalReadersN( t _uninstallHandlert getattrR R t removeReadert connectionLostt cleart disconnectAllt getDelayedCallst cancel( R t reactort readert callst c( ( sG /usr/lib/python2.7/dist-packages/twisted/internet/test/reactormixins.pyt unbuildReactorm s c sI y$ d d l m } d d l m } Wn t k r7 n. Xt | | re | j | k re t d n y | j Wn6 t j d d | j t t j n X| j d k r2t f d | j } | r2| j t d t j d j g | D] } t | ^ q f q2n | j | j S( sK Create and return a reactor using C{self.reactorFactory}. i( t CFReactor( R su CFReactor uses APIs which manipulate global state, so it's not safe to run its own reactor-builder tests under itselfs Failed to install reactorc s | j S( N( t providedBy( t required( R ( sG /usr/lib/python2.7/dist-packages/twisted/internet/test/reactormixins.pyt <lambda>