Current Path : /usr/lib/python2.7/dist-packages/twisted/application/test/ |
Current File : //usr/lib/python2.7/dist-packages/twisted/application/test/test_internet.pyc |
ó ê=Nc @ sâ d Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z m Z d d l m Z m Z d e f d „ ƒ YZ e e e ƒ d e f d „ ƒ YZ e e e ƒ d e f d „ ƒ YZ d S( s: Tests for (new code in) L{twisted.application.internet}. iÿÿÿÿ( t implements( t verifyClass( t Factory( t TestCase( t StreamServerEndpointService( t IStreamServerEndpointt IListeningPort( t Deferredt CancelledErrort FakeServerc B s] e Z d Z e e ƒ d Z d Z d Z e ƒ Z d Z d „ Z d „ Z d „ Z d „ Z RS( sq In-memory implementation of L{IStreamServerEndpoint}. @ivar result: The L{Deferred} resulting from the call to C{listen}, after C{listen} has been called. @ivar factory: The factory passed to C{listen}. @ivar cancelException: The exception to errback C{self.result} when it is cancelled. @ivar port: The L{IListeningPort} which C{listen}'s L{Deferred} will fire with. @ivar listenAttempts: The number of times C{listen} has been invoked. @ivar failImmediately: If set, the exception to fail the L{Deferred} returned from C{listen} before it is returned. i c C s t ƒ | _ d S( N( t FakePortt port( t self( ( sJ /usr/lib/python2.7/dist-packages/twisted/application/test/test_internet.pyt __init__/ s c s_ ˆ j d 7_ | ˆ _ t d ‡ f d † ƒ ˆ _ ˆ j d k rX ˆ j j ˆ j ƒ n ˆ j S( sw Return a Deferred and store it for future use. (Implementation of L{IStreamServerEndpoint}). i t cancellerc s | j ˆ j ƒ S( N( t errbackt cancelException( t d( R ( sJ /usr/lib/python2.7/dist-packages/twisted/application/test/test_internet.pyt <lambda>; s N( t listenAttemptst factoryR t resultt failImmediatelyt NoneR ( R R ( ( R sJ /usr/lib/python2.7/dist-packages/twisted/application/test/test_internet.pyt listen3 s c C s | j j | j ƒ d S( s° Test code should invoke this method after causing C{listen} to be invoked in order to fire the L{Deferred} previously returned from C{listen}. N( R t callbackR ( R ( ( sJ /usr/lib/python2.7/dist-packages/twisted/application/test/test_internet.pyt startedListeningA s c C s | j j j d ƒ d S( s Test code should invoke this method after causing C{stopListening} to be invoked on the port fired from the L{Deferred} returned from C{listen} in order to cause the L{Deferred} returned from C{stopListening} to fire. N( R t deferredR R ( R ( ( sJ /usr/lib/python2.7/dist-packages/twisted/application/test/test_internet.pyt stoppedListeningJ s N( t __name__t __module__t __doc__R R R R R R R R R R R R R ( ( ( sJ /usr/lib/python2.7/dist-packages/twisted/application/test/test_internet.pyR s R c B s' e Z d Z e e ƒ d Z d „ Z RS( ss Fake L{IListeningPort} implementation. @ivar deferred: The L{Deferred} returned by C{stopListening}. c C s t ƒ | _ | j S( N( R R ( R ( ( sJ /usr/lib/python2.7/dist-packages/twisted/application/test/test_internet.pyt stopListeningb s N( R R R R R R R R ( ( ( sJ /usr/lib/python2.7/dist-packages/twisted/application/test/test_internet.pyR W s t TestEndpointServicec B st e Z d Z d „ Z d „ Z d d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z RS( s4 Tests for L{twisted.application.internet}. c C s4 t ƒ | _ t ƒ | _ t | j | j ƒ | _ d S( sp Construct a stub server, a stub factory, and a L{StreamServerEndpointService} to test. N( R t fakeServerR R R t svc( R ( ( sJ /usr/lib/python2.7/dist-packages/twisted/application/test/test_internet.pyt setUpo s c C s* | j j ƒ | j | j | j j ƒ d S( s‡ L{StreamServerEndpointService.privilegedStartService} calls its endpoint's C{listen} method with its factory. N( R# t privilegedStartServicet assertIdenticalR R"