
[XMc           @   s  d  Z  d d l Z d d l Z d d l 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 d d l m Z m Z m Z m Z d d l m Z m Z m Z d d	 l m Z d d
 l m Z m Z m Z d d l m Z d d l m  Z  m! Z! d d l" m# Z# m$ Z$ d d l% m& Z& m' Z' m( Z( d e j) f d     YZ* d e j+ f d     YZ, d e- f d     YZ. d f  d     YZ/ d   Z0 d e j1 f d     YZ2 d e j1 f d     YZ3 d e j4 f d     YZ5 d e j6 f d     YZ7 e j8 e5 e7  d  e j4 f d!     YZ9 d"   Z: e j; e9 e:  d# e j1 f d$     YZ< d% e j= f d&     YZ> d' e j1 f d(     YZ? d) e j= f d*     YZ@ d+ e jA f d,     YZB e j8 e@ eB  d- e jA f d.     YZC e j8 e> eC  d/ e j1 f d0     YZD d1 e j1 f d2     YZE d3 e j1 f d4     YZF d5 e j1 f d6     YZG d7 e j4 e j6 e- f d8     YZH e j8 eH eH  d9 e j4 e j6 e- f d:     YZI e j8 eI eI  d; e j= e jA e- f d<     YZJ e j8 eJ eJ  d= e jK f d>     YZL d? e jK f d@     YZM dA e jN f dB     YZO dC e jP f dD     YZQ dE e jN f dF     YZR dG e jN f dH     YZS dI dJ ZT eU aV eU aW dK   ZX dL e j1 f dM     YZY dN e j1 f dO     YZZ dP e jN f dQ     YZ[ dR e j\ f dS     YZ] dT e j^ f dU     YZ_ dV e j1 f dW     YZ` e j8 e] e_  dX e jN f dY     YZa dZ eb f d[     YZc d\ e j4 f d]     YZd d^ e j1 f d_     YZe d` e jf f da     YZg db e j+ f dc     YZh dd e- f de     YZi df e j) f dg     YZj dh e jN f di     YZk dj f  dk     YZl dl e jN f dm     YZm dn e	 f do     YZn dp f  dq     YZo dr e jN f ds     YZp dt e jN f du     YZq dv e jN f dw     YZr d S(x   s   
Tests for Perspective Broker module.

TODO: update protocol level tests to use new connection API, leaving
only specific tests for old API.
iN(   t   StringIO(   t
   implementst	   Interface(   t   Version(   t   unittest(   t   pbt   utilt   publisht   jelly(   t   protocolt   maint   reactor(   t   ConnectionRefusedError(   t   Deferredt   gatherResultst   succeed(   t   WrappingFactory(   t   failuret   log(   t   UnauthorizedLogint   UnhandledCredentials(   t   portalt   checkerst   credentialst   Dummyc           B   s   e  Z d    Z RS(   c         C   s   t  | t  r d Sd Sd  S(   Ns   hello world!s   goodbye, cruel world!(   t
   isinstancet   DummyPerspective(   t   selft   user(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   view_doNothing    s    (   t   __name__t
   __module__R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR      s   R   c           B   s   e  Z d  Z d   Z RS(   sE   
    An L{IPerspective} avatar which will be used in some tests.
    c         C   s   t    S(   N(   R   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   perspective_getDummyViewPoint+   s    (   R   R   t   __doc__R    (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   '   s   t
   DummyRealmc           B   s   e  Z e e j  d    Z RS(   c         G   s:   x3 | D]+ } | t  j k r | t |  d   f Sq Wd  S(   Nc           S   s   d  S(   N(   t   None(    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   <lambda>6   s    (   R   t   IPerspectiveR   (   R   t   avatarIdt   mindt
   interfacest   iface(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   requestAvatar3   s    (   R   R   R   R   t   IRealmR*   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR"   0   s   t   IOPumpc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s   
    Utility to pump data between clients and servers for protocol testing.

    Perhaps this is a utility worthy of being in protocol.py?
    c         C   s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   t   clientt   servert   clientIOt   serverIO(   R   R-   R.   R/   R0   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   __init__?   s    			c         C   s=   t  j    d } x& |  j   r8 t  j    | k r d Sq Wd S(   s   
        Pump until there is no more input or output. This does not run any
        timers, so don't use it with any code that calls reactor.callLater.
        i   N(   t   timet   pump(   R   t   timeout(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   flushE   s    c         C   s   |  j  j d  |  j j d  |  j  j   } |  j j   } |  j  j d  |  j j d  |  j  j   |  j j   |  j j j   |  j j j   x | D] } |  j j	 |  q Wx | D] } |  j j	 |  q W| s | r d Sd Sd S(   sX   
        Move data back and forth.

        Returns whether any data was moved.
        i    i   N(
   R/   t   seekR0   t   readt   truncateR-   t	   transportt   _checkProducerR.   t   dataReceived(   R   t   cDatat   sDatat   byte(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR3   P   s"    (   R   R   R!   R1   R5   R3   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR,   9   s   		c          C   s   t  j   }  t j d d  } t  j t j t   | g   } | j d  } t	   } t	   } |  j
 t j |   | j
 t j |   t |  | | |  } | j   |  | | f S(   s4   
    Returns a 3-tuple: (client, server, pump).
    t   guests	   127.0.0.1(   s	   127.0.0.1(   R   t   BrokerR   t'   InMemoryUsernamePasswordDatabaseDontUset   PBServerFactoryR   t   PortalR"   t   buildProtocolR    t   makeConnectionR	   t   FileWrapperR,   R5   (   t   clientBrokert   checkert   factoryt   serverBrokert   clientTransportt   serverTransportR3   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   connectedServerAndClientj   s    !		
t   SimpleRemotec           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  | d S(   Ni   (   t   arg(   R   RO   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_thunk~   s    	c         C   s   t     d  S(   N(   t	   Exception(   R   RO   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_knuth   s    (   R   R   RP   RR   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRN   }   s   	t   NestedRemotec           B   s   e  Z d    Z RS(   c         C   s   t    S(   N(   RN   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_getSimple   s    (   R   R   RT   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRS      s   t
   SimpleCopyc           B   s   e  Z d    Z RS(   c         C   s)   d |  _  i d d 6|  _ d g |  _ d  S(   Ni   t   Worldt   Hellot   test(   t   xt   yt   z(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1      s    	(   R   R   R1   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRU      s   t   SimpleLocalCopyc           B   s   e  Z RS(    (   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR\      s   t   SimpleFactoryCopyc           B   s   e  Z d  Z i  Z d   Z RS(   s]   
    @cvar allIDs: hold every created instances of this class.
    @type allIDs: C{dict}
    c         C   s   | |  _  |  t j | <d  S(   N(   t   idR]   t   allIDs(   R   R^   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1      s    	(   R   R   R!   R_   R1   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR]      s   c         C   s   |  j  d d  } | d k r: t d t |   f   n  | t j k rb t d t j f   n  t j | } | s t d   n  | S(   sl   
    Factory of L{SimpleFactoryCopy}, getting a created instance given the
    C{id} found in C{state}.
    R^   s(   factory copy state has no 'id' member %ss   factory class has no ID: %ss&   factory method found no object with idN(   t   getR#   t   RuntimeErrort   reprR]   R_   (   t   statet   stateIdt   inst(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   createFactoryCopy   s    t
   NestedCopyc           B   s   e  Z d    Z d   Z RS(   c         C   s   t    S(   N(   RU   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_getCopy   s    c         C   s
   t  |  S(   N(   R]   (   R   t   value(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_getFactory   s    (   R   R   Rh   Rj   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRg      s   	t   SimpleCachec           B   s   e  Z d    Z RS(   c         C   s)   d |  _  i d d 6|  _ d g |  _ d  S(   Ni   RV   RW   RX   (   RY   RZ   R[   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	   __init___   s    	(   R   R   Rl   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRk      s   t   NestedComplicatedCachec           B   s   e  Z d    Z d   Z RS(   c         C   s   t    |  _ d  S(   N(   t   VeryVeryComplicatedCacheablet   c(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1      s    c         C   s   |  j  S(   N(   Ro   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_getCache   s    (   R   R   R1   Rp   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRm      s   	Rn   c           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s   d |  _  d |  _ d |  _ d  S(   Ni   i   i   (   RY   RZ   t   foo(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1      s    		c         C   s    d |  _  |  j j d d  d  S(   Ni   Rq   (   Rq   t   observert
   callRemote(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   setFoo4   s    	c         C   s+   | |  _  i |  j d 6|  j d 6|  j d 6S(   NRY   RZ   Rq   (   Rr   RY   RZ   Rq   (   R   t   perspectiveRr   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   getStateToCacheAndObserveFor   s    	
c         C   s9   t  j d  | j d  | |  j k r5 d  |  _ n  d  S(   Ns   stopped observingt   end(   R   t   msgRs   Rr   R#   (   R   Ru   Rr   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   stoppedObserving   s    (   R   R   R1   Rt   Rv   Ry   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRn      s   			t   RatherBaroqueCachec           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  d  S(   N(   Rq   (   R   t   newFoo(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   observe_foo   s    c         C   s   t  j d  d  S(   Ns   the end of things(   R   Rx   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   observe_end   s    (   R   R   R|   R}   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRz      s   	t   SimpleLocalCachec           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s   |  j  j |  d  S(   N(   t   __dict__t   update(   R   Rc   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   setCopyableState   s    c         C   s   |  j  S(   N(   t   check(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   checkMethod   s    c         C   s   |  S(   N(    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	   checkSelf   s    c         C   s   d S(   Ni   (    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR      s    (   R   R   R   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR~      s   			t   NestedCachec           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   t    |  _ d  S(   N(   Rk   RY   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1     s    c         C   s   |  j  |  j  g S(   N(   RY   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRp     s    c         C   s   |  j  | k S(   N(   RY   (   R   t   cache(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_putCache  s    (   R   R   R1   Rp   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR      s   		t
   Observablec           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s   g  |  _  d  S(   N(   t	   observers(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1     s    c         C   s   |  j  j |  d  S(   N(   R   t   append(   R   t   obs(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_observe  s    c         C   s   |  j  j |  d  S(   N(   R   t   remove(   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_unobserve  s    c         C   s+   x$ |  j  D] } | j d |  |  q
 Wd  S(   Nt   notify(   R   Rs   (   R   t   objRr   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s    (   R   R   R1   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s   			t   DeferredRemotec           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s   d |  _  d  S(   Ni    (   t   run(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1     s    c         C   s   | |  _  | d S(   Ni   (   R   (   R   RO   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   runMe  s    	c         C   s   d s t  d  d  S(   Ni    s   shouldn't have been run!(   t   AssertionError(   R   RO   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	   dontRunMe"  s    c         C   s,   t    } | j |  j |  j  | |  _ | S(   so   
        Return a L{Deferred} to be fired on client side. When fired,
        C{self.runMe} is called.
        (   R   t   addCallbacksR   R   t   d(   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_doItLater%  s    		(   R   R   R1   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s   			t   Observerc           B   s   e  Z d  Z d Z d   Z RS(   i    c         C   s-   | |  _  |  j d |  _ | j d |   d  S(   Ni   t	   unobserve(   R   t   notifiedRs   (   R   t   otherR   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_notify3  s    	N(   R   R   R   R#   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   0  s   t   NewStyleCopyc           B   s   e  Z d    Z RS(   c         C   s   | |  _  d  S(   N(   t   s(   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1   :  s    (   R   R   R1   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   9  s   t   NewStyleCopy2c           B   s,   e  Z d  Z d  Z d Z d   Z d   Z RS(   i    i   c         C   s+   t  j d 7_ t j |   } d | _ | S(   Ni   i   (   R   t	   allocatedt   objectt   __new__Ri   (   R   Re   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   D  s    	c         C   s   t  j d 7_ d  S(   Ni   (   R   t   initialized(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1   J  s    (   R   R   R   R   Ri   R   R1   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   ?  s
   	t   NewStyleCacheCopyc           B   s   e  Z d    Z RS(   c         C   s   |  j  S(   N(   R   (   R   Ru   Rr   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRv   Q  s    (   R   R   Rv   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   P  s   t   Echoerc           B   s   e  Z d    Z RS(   c         C   s   | S(   N(    (   R   t   st(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_echoX  s    (   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   W  s   t   CachedReturnerc           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1   ]  s    c         C   s   |  j  S(   N(   R   (   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_giveMeCache_  s    (   R   R   R1   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   \  s   	t   NewStyleTestCasec           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c            s   t  j t      _ t   j    _ t j d   j    _ t  j	   } t j
 d   j j   j |    f d   } | j   j |  S(   sY   
        Create a pb server using L{Echoer} protocol and connect a client to it.
        i    t	   localhostc            s   |    _  d  S(   N(   t   ref(   R   (   R   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   gotRootn  s    (   R   RB   R   t   serverFactoryR   t   wrapperR   t	   listenTCPR.   t   PBClientFactoryt
   connectTCPt   getHostt   portt   getRootObjectt   addCallback(   R   t   clientFactoryR   (    (   R   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   setUpd  s    c         C   s_   d t  _ d t  _ d t  _ |  j j j j   x! |  j j	 D] } | j j   q; W|  j
 j   S(   sp   
        Close client and server connections, reset values of L{NewStyleCopy2}
        class variables.
        i    i   (   R   R   R   Ri   R   t   brokerR9   t   loseConnectionR   t	   protocolsR.   t   stopListening(   R   t   proto(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   tearDowns  s    			c            sD   t  d     j j d   }    f d   } | j |  | S(   sY   
        Create a new style object, send it over the wire, and check the result.
        Ri   t   echoc            s@     j  t |  t     j |  j d    j |   k  d  S(   NRi   (   t
   failUnlessR   R   t   failUnlessEqualR   t   failIf(   t   res(   R   t   orig(    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   cb  s    (   R   R   Rs   R   (   R   R   R   (    (   R   R   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_newStyle  s
    c            sg   t       j t  j d    j t  j d    j j d   }    f d   } | j |  | S(   sN   
        Send a new style object and check the number of allocations.
        i   R   c            sf     j  t |  t     j |  j d    j t j d    j t j d    j |   k  d  S(   Ni   i   i   (   R   R   R   R   Ri   R   R   R   (   R   (   R   R   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s
    (   R   R   R   R   R   Rs   R   (   R   R   R   (    (   R   R   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
   test_alloc  s    	(   R   R   R   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   c  s   			t   ConnectionNotifyServerFactoryc           B   s&   e  Z d  Z d Z d   Z d   Z RS(   sj  
    A server factory which stores the last connection and fires a
    L{Deferred} on connection made. This factory can handle only one
    client connection.

    @ivar protocolInstance: the last protocol instance.
    @type protocolInstance: C{pb.Broker}

    @ivar connectionMade: the deferred fired upon connection.
    @type connectionMade: C{Deferred}
    c         C   s#   t  j j |  |  t   |  _ d S(   s)   
        Initialize the factory.
        N(   R   RB   R1   R   t   connectionMade(   R   t   root(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1     s    c         C   s<   | |  _  |  j d } |  _ | d k	 r8 | j d  n  d S(   sF   
        Store the protocol and fire the connection deferred.
        N(   t   protocolInstanceR   R#   t   callback(   R   R	   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   clientConnectionMade  s    	N(   R   R   R!   R#   R   R1   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s   	t   NewStyleCachedTestCasec           B   s#   e  Z d    Z d   Z d   Z RS(   c            s   t      _ d   j _ t j d t t   j      _ t j	   } t j
 d   j j   j |    f d   } | j   j |  }   j j j } t | | g  S(   si   
        Create a pb server using L{CachedReturner} protocol and connect a
        client to it.
        Ri   i    R   c            s   |    _  d  S(   N(   R   (   R   (   R   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s    (   R   R   R   R   R   R   R   R.   R   R   R   R   R   R   R   RI   R   R   (   R   R   R   t   d1t   d2(    (   R   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s    	c         C   s6   |  j  j j j j   |  j j j j   |  j  j   S(   s6   
        Close client and server connections.
        (   R.   RI   R   R9   R   R   R   R   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s    c            s8     j  j d   j  }   f d   } | j |  | S(   sK   
        Get the object from the cache, and checks its properties.
        t   giveMeCachec            sC     j  t |  t     j |  j d    j |    j k  d  S(   NRi   (   R   R   R   R   R   R   R   (   R   (   R   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s    (   R   Rs   R   R   (   R   R   R   (    (   R   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_newStyleCache  s    (   R   R   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s   			t   BrokerTestCasec           B   s   e  Z d Z d    Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s)   y t  j d  Wn t k
 r$ n Xd  S(   Ns   None-None-TESTING.pub(   t   ost   unlinkt   OSError(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s    c         C   s   |  j  d | f  d  S(   Ns(   This should cause a return value, not %s(   t   fail(   R   t   error(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   thunkErrorBad  s    c         C   s   | |  _  d  S(   N(   t   thunkResult(   R   t   result(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   thunkResultGood  s    c         C   s   d  S(   N(    (   R   t   tb(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   thunkErrorGood  s    c         C   s   |  j  d | f  d  S(   Ns"   This should cause an error, not %s(   R   (   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   thunkResultBad  s    c   	      C   s   t    \ } } } d t j f d     Y} d t j f d     Y} | j d |    | j d  } |   } |   } | j d | |  | j   | j   | j   |  j | j | d  |  j	 | j
 d  | j
 d   d  S(   Nt   Xc           B   s   e  Z d    Z RS(   c         S   s   | |  _  d  S(   N(   t   caught(   R   RO   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_catch	  s    (   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s   t   Yc           B   s   e  Z d    Z RS(   c         S   s   | j  d |  d  S(   Nt   catch(   Rs   (   R   t   at   b(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_throw  s    (   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s   RZ   t   throws   X should have caught Z(   RM   R   t   Referenceablet   setNameForLocalt   remoteForNameRs   R3   t   assertIdenticalR   t   assertEqualst   remoteMethod(	   R   Ro   R   R3   R   R   RZ   RY   R[   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_reference  s    		


c         C   s   t    \ } } } x | | f | | f f D] \ } } t   } | j d |  | j d  } d |  _ | j d |  j d  j |  j |  j  | j	   | j	   |  j
 |  j |  j d  q+ Wd  S(   NRq   i   t   thunki   s   result wasn't received.(   RM   RN   R   R   t   expectedThunkResultRs   R   R   R   R3   R   R   (   R   Ro   R   R3   RY   RZ   Rq   t   bar(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_result  s    %		

c         C   s   | |  _  d  S(   N(   t   nestedRemote(   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   refcountResult/  s    c   
      C   s   g  } g  } t    \ } } } t   } | j d |  | j d  } x` t t j d  D]K } | j j sx | j j r| Pn  | j	 d  j
 | j | j  | j   qZ Wt j d }	 |  j | j j d  |  j t |  |	 d |	 t |  f  d  S(   NRq   i
   t	   getSimplei   s   transport was not closeds   expected %s got %s(   RM   RS   R   R   t   xrangeR   t   MAX_BROKER_REFSR9   t   closedRs   R   R   R3   t
   assertTrueR   t   len(
   R   t   lt   eRo   R   R3   Rq   RY   t   ignot   expected(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_tooManyRefs2  s    	c         C   s   t    \ } } } t   } | j d |  | j d  } | j d  j |  j |  j  | j   | j   |  j	 |  j
 j d  |  j	 |  j
 j d d  |  j	 |  j
 j d d  d  S(   NRq   t   getCopyi   RW   RV   i    RX   (   RM   Rg   R   R   Rs   R   R   R   R3   R   R   RY   RZ   R[   (   R   Ro   R   R3   Rq   RY   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	   test_copyC  s    	

c         C   s   t    \ } } } t   } t   } | j d |  | j d  } | j d |  | j   | j d  | j   | j   | j d  | j   | j   |  j | j	 d  d  |  j | j	 d d  d  S(   NR   t   observei   i
   s   didn't notifys   notified too much(   RM   R   R   R   R   Rs   R3   R   t   assertNotIdenticalR   R#   R   (   R   Ro   R   R3   R   R   t   ra(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_observeP  s    		




c         C   s   t    \ } } } t   } | j d |  | j d  } | j   | j   g  } | j d  j | j  | j   | j   |  j | j	 d  | j
 j d  |  j | j	 d d  | j   | j   |  j | d d d  d  S(	   NR   t	   doItLaters   Deferred method run too early.i   s   Deferred method run too late.i    i   s   Incorrect result.(   RM   R   R   R   R3   Rs   R   R   t   assertFalseR   R   R   R   (   R   Ro   R   R3   R   R   t   results(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
   test_deferd  s     	
 

 

 
c         C   s   t    \ } } } t   } | j d |  | j d  } | j d  j |  j |  j  | j   | j   |  j	 j
 } |  j | | j  |  `	 t j d k r t j   n  | j   | j   | j   |  j | | j  d  S(   NRq   R   i   (   RM   RS   R   R   Rs   R   R   R   R3   R   t   luidt   assertInt   localObjectst   syst
   hexversiont   gct   collectt   assertNotIn(   R   Ro   R   R3   Rq   R   t   rluid(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_refcountt  s"    	




c         C   s	  t    \ } } } t   } t   } | j } | j d |  | j d |  | j d  } | j d  } g  }	 | j d  j |	 j  j	 |	 j  | j d  j |	 j  j	 |	 j  g  }
 | j d  j |
 j  | j d  j |
 j  | j
   |  j |
 d j d  |  j |
 d j d  |  j |
 d j d  | j   | j
   |  j |
 d j d  |  j t |	  d  |	 d d } |  j | j   j | d	  |  j | j   | d
  g  } | j d |  j | j  | j
   |  j | d  |  j | j d  | j d   | j } |
 d j } |  j | | j d  ~	 ~ | j
   ~
 ~ | j
   t j d k rt j   n  | j
   |  j | | j d  |  j | | j d  |  j | | j d  |  j | | j d  |  j | j  d  d  d  S(   NR   t   xxxt   getCachei    i   i   i   i   s   potential refcounting issues!   other potential refcounting issuet   putCaches   remote cache doesn't have iti   s   Server still had it after GCs   Client still had it after GCs!   Server still had complex after GCs!   Client still had complex after GCs   observer was not removed("   RM   R   Rm   Ro   R   R   Rs   R   R   t
   addErrbackR5   R   RY   RZ   Rq   Rt   R   R   R   t   im_selfR   R   R   R  R  t   remotelyCachedObjectsR  R  R  R  R  t   locallyCachedObjectsRr   R#   (   R   Ro   R   R3   R   t   obj2t   vcct   o2t   o3t   collt   complext   cpt   col2R  t   baroqueLuid(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
   test_cache  sr    			



	


c         C   sc  y t  j d  Wn t k
 r$ n Xt   \ } } } t   } | j d |  | j d  } g  } | j d  j | j	 |  j
  | j   | j   } |  j | j d  |  j | j d  |  j | j d  |  j | j d  t   \ } } } | j d |  | j d  } | j d  j | j	 |  j
  | j   | j   } |  j | j d  d  S(   Ns   None-None-TESTING.pubRq   t   getPubi   i    (   R   R   R   RM   t   GetPublisherR   R   Rs   R   R   R   R5   t   popR   t   activateCalledt   isActivatedt   yayIGotPublishedt   _wasCleanWhenLoaded(   R   Ro   R   R3   Rq   R   t   accumR   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_publishable  s.    	

c         C   s   | j  |  _ d  S(   N(   R^   R   (   R   t   val(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   gotCopy  s    c         C   s   t    \ } } } d } t   } | j d |  | j d  } | j d |  j |  j |  j  | j   | j   | j   |  j	 |  j
 | d |  j
 f  d  S(   Nic   Rq   t
   getFactorys#   ID not correct on factory object %s(   RM   Rg   R   R   Rs   R   R1  R   R3   R   R   (   R   Ro   R   R3   t   IDR   RY   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_factoryCopy  s    	


N(   R   R   R#   R   R   R   R   R   R   R   R   R   R  R  R  R  R  R&  R/  R1  R4  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s$   														F		t
   helloworldi2   c          O   s   |  a  | a d  S(   N(   t   callbackArgst   callbackKeyword(   t   argst   kw(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   finishedCallback	  s    t	   Pagerizerc           B   s   e  Z d    Z d   Z RS(   c         O   s!   | | | |  _  |  _ |  _ d  S(   N(   R   R8  R9  (   R   R   R8  R9  (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1     s    c         C   s9   t  j | t d |  j |  j |  j  d  |  _ |  _ d  S(   Nid   (   R   t   StringPagert	   bigStringR   R8  R9  R#   (   R   t	   collector(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_getPages  s    (   R   R   R1   R?  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR;    s   	t   FilePagerizerc           B   s    e  Z d Z d    Z d   Z RS(   c         O   s*   | |  _  | | | |  _ |  _ |  _ d  S(   N(   t   filenameR   R8  R9  (   R   RA  R   R8  R9  (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1     s    	c         C   sD   t  j | t |  j  |  j |  j |  j  |  _ d  |  _ |  _ d  S(   N(	   R   t	   FilePagert   fileRA  R   R8  R9  t   pagerR#   (   R   R>  (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR?     s    N(   R   R   R#   RD  R1   R?  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR@    s   	t   PagingTestCasec           B   sD   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s0   
    Test pb objects sending data by pages.
    c         C   s<   |  j    |  _ t |  j d  } | j t  | j   d S(   s?   
        Create a file used to test L{util.FilePager}.
        t   wN(   t   mktempRA  RC  t   writeR=  t   close(   R   t   fd(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   ,  s    c         C   s   t    \ } } } | j d t t d d d  | j d  } g  } t j | d  j | j  x | sx | j	   qe W|  j
 d j | d  t d  |  j
 t d d	  |  j
 t i d d 6d	  d
 S(   sg   
        Test L{util.StringPager}, passing a callback to fire when all pages
        are sent.
        Rq   t   helloRi   i
   t   getPagest    i    s'   Pages received not equal to pages sent!s   Completed callback not invokedN(   RK  (   RM   R   R;  R:  R   R   t   getAllPagesR   R   R3   R   t   joinR=  R6  R7  (   R   Ro   R   R3   RY   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_pagingWithCallback6  s    	c         C   s   t    \ } } } | j d t d   | j d  } g  } t j | d  j | j  x | so | j	   q\ W|  j
 d j | d  t d  d S(   s>   
        Test L{util.StringPager} without a callback.
        Rq   RL  RM  i    s'   Pages received not equal to pages sent!N(   RM   R   R;  R#   R   R   RN  R   R   R3   R   RO  R=  (   R   Ro   R   R3   RY   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_pagingWithoutCallbackJ  s    	c   
      C   s   |  j    } t | d  } | j   t   \ } } } t | d
  } | j d |  | j d  } g  } t j	 | d  j
 | j  d }	 x+ | r |	 d k r | j   |	 d 8}	 q W|	 s |  j d  n  |  j d j | d  d d	  d
 S(   s@   
        Test L{util.FilePager}, sending an empty file.
        RF  R   RL  i
   i    i   s   getAllPages timed outRM  s'   Pages received not equal to pages sent!N(   RG  RC  RI  RM   R@  R#   R   R   R   RN  R   R   R3   R   R   RO  (
   R   t   filenameEmptyRJ  Ro   R   R3   t	   pagerizerRY   R   t   ttl(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_emptyFilePagingY  s"    

c         C   s   t    \ } } } t |  j t d d d } | j d |  | j d  } g  } t j | d  j | j	  x | s | j
   qq W|  j d j | d  t d  |  j t d d	  |  j t i d d 6d	  |  j | j j g   d
 S(   s   
        Test L{util.FilePager}, passing a callback to fire when all pages
        are sent, and verify that the pager doesn't keep chunks in memory.
        t   frodoRi   i	   R   RL  RM  i    s'   Pages received not equal to pages sent!s   Completed callback not invokedN(   RV  (   RM   R@  RA  R:  R   R   R   RN  R   R   R3   R   RO  R=  R6  R7  RD  t   chunks(   R   Ro   R   R3   RS  RY   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_filePagingWithCallbackp  s     	c         C   s   t    \ } } } t |  j d  } | j d |  | j d  } g  } t j | d  j | j	  x | s{ | j
   qh W|  j d j | d  t d  |  j | j j g   d S(   s<   
        Test L{util.FilePager} without a callback.
        R   RL  RM  i    s'   Pages received not equal to pages sent!N(   RM   R@  RA  R#   R   R   R   RN  R   R   R3   R   RO  R=  RD  RW  (   R   Ro   R   R3   RS  RY   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_filePagingWithoutCallback  s    	(	   R   R   R!   R   RP  RQ  RU  RX  RY  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRE  '  s   	
				t   DumbPublishablec           B   s   e  Z d    Z RS(   c         C   s   i d d 6S(   Ni   R,  (    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   getStateToPublish  s    (   R   R   R[  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRZ    s   t   DumbPubc           B   s   e  Z d    Z RS(   c         C   s   d |  _  d  S(   Ni   (   R*  (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	   activated  s    (   R   R   R]  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR\    s   R(  c           B   s   e  Z d    Z d   Z RS(   c         C   s   t  d  |  _ d  S(   Nt   TESTING(   RZ  t   pub(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1     s    c         C   s   |  j  S(   N(   R_  (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_getPub  s    (   R   R   R1   R`  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR(    s   	t   DisconnectionTestCasec           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s'   
    Test disconnection callbacks.
    c         G   s   t  d | f   d  S(   Ns    I shouldn't have been called: %s(   Ra   (   R   R8  (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s    c         C   s   d |  _  d S(   s.   
        Called on broker disconnect.
        i   N(   t   gotCallback(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   gotDisconnected  s    c         C   s    |  j  | |  j  d |  _ d S(   s7   
        Called on RemoteReference disconnect.
        i   N(   R   t   remoteObjectt   objectCallback(   R   t   o(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   objectDisconnected  s    c         C   s   t    \ } } } | j   | j d t    | j d  } g  } | j d t    j | j  | j	   |  j
 t |  d  d  S(   NRf  t
   setBadCopyi   (   RM   R3   R   t
   BadCopySetR   Rs   t   BadCopyableR  R   R5   R   R   (   R   Ro   R   R3   t   gR   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_badSerialization  s    

c         C   s  t    \ } } } | j   | j d t    | j d  } | j   | j   | j   | j |  j  |  j |  j | j  | j	 |  j  |  j
 |  j | j  | j |  j  |  j | j | j  |  j |  j | j  | j	 |  j  |  j
 | j | j  |  j
 |  j | j  | j |  j  | j |  j  | |  _ | j t j t j   |  j |  j  |  j |  j  d  S(   NRf  (   RM   R3   R   RN   R   t   notifyOnDisconnectR   R  t   disconnectst   dontNotifyOnDisconnectR  t   _disconnectedt   disconnectCallbacksRc  Rg  Rd  t   connectionLostR   t   FailureR
   t   CONNECTION_DONER   Rb  Re  (   R   Ro   R   R3   t   r(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_disconnection  s.    



	(   R   R   R!   R   Rc  Rg  Rl  Rv  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRa    s   				
t   FreakOutc           B   s   e  Z RS(    (   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRw    s   Rj  c           B   s   e  Z d    Z RS(   c         C   s   t     d  S(   N(   Rw  (   R   t   p(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   getStateToCopyFor  s    (   R   R   Ry  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRj    s   Ri  c           B   s   e  Z d    Z RS(   c         C   s   d  S(   N(   R#   (   R   t   bc(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   remote_setBadCopy  s    (   R   R   R{  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyRi    s   t   LocalRemoteTestc           B   s/   e  Z d  Z d   Z d  d d  Z d   Z RS(   i    c         C   s   | d S(   Ni   (    (   R   RY   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	   sync_add1  s    i   c         C   s   | | S(   N(    (   R   RY   RZ   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	   async_add  s    c         C   s   t     d  S(   N(   Ra   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
   async_fail  s    (   R   R   t   reportAllTracebacksR}  R~  R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR|    s   	t   MyPerspectivec           B   sR   e  Z d  Z e e j  e Z Z d   Z	 d   Z
 d   Z d   Z d   Z RS(   s   
    @ivar loggedIn: set to C{True} when the avatar is logged in.
    @type loggedIn: C{bool}

    @ivar loggedOut: set to C{True} when the avatar is logged out.
    @type loggedOut: C{bool}
    c         C   s   | |  _  d  S(   N(   R&   (   R   R&   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1     s    c         C   s   |  j  S(   sT   
        Return the avatar identifier which was used to access this avatar.
        (   R&   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   perspective_getAvatarId  s    c         C   s   t    S(   N(   t   MyView(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   perspective_getViewPoint$  s    c         C   s   | | S(   s   
        Add the given objects and return the result.  This is a method
        unavailable on L{Echoer}, so it can only be invoked by authenticated
        users who received their avatar from L{TestRealm}.
        (    (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   perspective_add(  s    c         C   s   t  |  _ d  S(   N(   t   Truet	   loggedOut(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   logout1  s    (   R   R   R!   R   R   R%   t   Falset   loggedInR  R1   R  R  R  R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s   
					t	   TestRealmc           B   s#   e  Z d  Z e Z d Z d   Z RS(   s  
    A realm which repeatedly gives out a single instance of L{MyPerspective}
    for non-anonymous logins and which gives out a new instance of L{Echoer}
    for each anonymous login.

    @ivar lastPerspective: The L{MyPerspective} most recently created and
        returned from C{requestAvatar}.

    @ivar perspectiveFactory: A one-argument callable which will be used to
        create avatars to be returned from C{requestAvatar}.
    c         C   s   | t  j k s t  | d k s' t  | t j k rL t  j t   d   f S|  j |  |  _ t |  j _	 t  j |  j |  j j
 f Sd S(   s   
        Verify that the mind and interface supplied have the expected values
        (this should really be done somewhere else, like inside a test method)
        and return an avatar appropriate for the given identifier.
        s   BRAINS!c           S   s   d  S(   N(   R#   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR$   O  s    N(   R   R%   R   R   t	   ANONYMOUSR   t   perspectiveFactoryt   lastPerspectiveR  R  R  (   R   R&   R'   t	   interface(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR*   F  s    N(   R   R   R!   R  R  R#   R  R*   (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  6  s   R  c           B   s   e  Z d    Z RS(   c         C   s   t  | t  S(   N(   R   R  (   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
   view_check[  s    (   R   R   R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  Y  s   t   NewCredTestCasec           B   s   e  Z d  Z d   Z d   Z e j d  Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s=   
    Tests related to the L{twisted.cred} support in PB.
    c         C   sj   t    |  _ t j |  j  |  _ t |  j  |  _ t j d |  j d d |  _ |  j j	   j |  _
 d S(   s   
        Create a portal with no checkers and wrap it around a simple test
        realm.  Set up a PB server on a TCP port which serves perspectives
        using that portal.
        i    R  s	   127.0.0.1N(   R  t   realmR   RC   R   RI   R   R   R   R   t   portno(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   d  s
    c         C   s   |  j  j   S(   s=   
        Shut down the TCP port created by L{setUp}.
        (   R   R   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR   q  s    c         C   sG   |   } | j    } t j d |  j |  } |  j | j  | | f S(   sG  
        Create a connection to the test server.

        @param clientFactory: the factory class used to create the connection.

        @return: a tuple (C{factory}, C{deferred}), where factory is an
            instance of C{clientFactory} and C{deferred} the L{Deferred} firing
            with the PB root object.
        s	   127.0.0.1(   R   R   R   R  t
   addCleanupt
   disconnect(   R   R   RI   t   rootObjDeferredt	   connector(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   getFactoryAndRootObjectx  s
    
	c            s1     j    \  }    f d   } | j |  S(   sw   
        Assert only that L{PBClientFactory.getRootObject}'s Deferred fires with
        a L{RemoteReference}.
        c            s:     j  |  t j  t   } |  j | j   j   | S(   N(   t   assertIsInstanceR   t   RemoteReferenceR   Rm  R   R  (   t   rootObjt   disconnectedDeferred(   R   RI   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   gotRootObject  s
    	
(   R  R   (   R   R  R  (    (   R   RI   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_getRootObject  s    c            s1     j    \  }    f d   } | j |  S(   s   
        Test that when a connection is lost, calling a method on a
        RemoteReference obtained from it raises DeadReferenceError.
        c            sF   t    }   j | j     f d   } | j |   j   | S(   Nc            s     j  t j  j d  d  S(   Nt   method(   t   assertRaisesR   t   DeadReferenceErrorRs   (   t   ign(   R   R  (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   lostConnection  s    (   R   Rm  R   R   R  (   R  R  R  (   R   RI   (   R  s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s    	
(   R  R   (   R   R  R  (    (   R   RI   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_deadReferenceError  s    c            sM   d t  j f d     Y}   j |  \  }    f d   } | j |  S(   s   
        Test that if the L{reconnecting} flag is passed with a True value then
        a remote call made from a disconnection notification callback gets a
        result successfully.
        t   ReconnectOncec           B   s   e  Z e Z d    Z RS(   c         S   s?   |  j  } t |  _  | r& | j   n  t j j |  | | |  S(   N(   t   reconnectedAlreadyR  t   connectR   R   t   clientConnectionLost(   R   R  t   reasont   reconnecting(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s    
		(   R   R   R  R  R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s   c            sU     j  |  t j  t   } |  j | j   j      f d   } | j |  S(   Nc            s+    j    }    f d   } | j |  S(   Nc            s:     j  |  t j  t   } |  j | j   j   | S(   N(   R  R   R  R   Rm  R   R  (   t   anotherRootObjR   (   R   RI   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   gotAnotherRootObject  s
    	
(   R   R   (   R  R   R  (   R   RI   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   disconnected  s    (   R  R   R  R   Rm  R   R  R   (   R  R   R  (   R   RI   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s    	
(   R   R   R  R   (   R   R  R  R  (    (   R   RI   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_clientConnectionLost  s    
c         C   sH   |  j  j d  } | j t j t     | j t j t	 j
   d S(   s   
        Test that if a Broker loses its connection without receiving any bytes,
        it doesn't raise any exceptions or log any errors.
        s	   127.0.0.1i90  N(   s	   127.0.0.1i90  (   RI   RD   RE   R	   RF   R    Rr  R   Rs  R
   Rt  (   R   t   serverProto(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_immediateClose  s    c         C   sV   t  j   } | j t j d d   } | j d t j t	 d    |  j
 | t	  S(   s   
        L{PBClientFactory.login} returns a L{Deferred} which is errbacked
        with the L{ConnectionRefusedError} if the underlying connection is
        refused.
        Rq   R   s!   Test simulated refused connectionN(   R   R   t   loginR   t   UsernamePasswordt   clientConnectionFailedR#   R   Rs  R   t   assertFailure(   R   R   t   loginDeferred(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_loginConnectionRefused  s    c            s3   t      |  j j j   f d    | j     S(   s   
        Helper method disconnecting the given client factory and returning a
        C{Deferred} that will fire when the server connection has noticed the
        disconnection.
        c              s     j  d   S(   N(   R   R#   (    (   R  (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR$     s    (   R   RI   R   Rm  R  (   R   t   ignoreRI   (    (   R  s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   _disconnect  s
    	
c            s     j  j t j d d   t j    t j d d  } d }  j | |  }    f d   } | j	 |    f d   } | j	 |  t
 j d   j   }   j | j  | S(   s   
        Test that login can be performed with IUsernamePassword credentials and
        that when the connection is dropped the avatar is logged out.
        R   t   passs   BRAINS!c            s9     j    j j j    j |  t j    j d    S(   N(	   R   R  R  R  R  R   R  R  R#   (   Ru   (   R   RI   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   cbLogin  s    c            s     j    j j j  d  S(   N(   R   R  R  R  (   t   ignored(   R   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   cbLogout  s    s	   127.0.0.1(   R   t   registerCheckerR   RA   R   R   R   R  R  R   R   R   R  R  R  (   R   t   credsR'   R   R  R  R  (    (   R   RI   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_loginLogout   s    	c            s   t     d t j f  f d     Y} |   j _   j j t j d d   t j	   } | j
 t j d d  d  }  f d   } | j |    f d   } | j |  | j   j |  t j d   j |  }   j | j  | S(	   s   
        If a L{RemoteReference} to an L{IPerspective} avatar is decrefed and
        there remain no other references to the avatar on the server, the
        avatar is garbage collected and the logout method called.
        t   EventPerspectivec              s&   e  Z d  Z d   Z   f d   Z RS(   sQ   
            An avatar which fires a Deferred when it is logged out.
            c         S   s   d  S(   N(    (   R   R&   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1   -  s    c            s     j  d   d  S(   N(   R   R#   (   R   (   R  (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  0  s    (   R   R   R!   R1   R  (    (   R  (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  )  s   	Rq   R   s   BRAINS!c            s     S(   N(    (   t   avatar(   R  (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
   cbLoggedIn:  s    c            s     j    j j j i   d  S(   N(   t   assertEqualRI   R   t   _localCleanup(   R  (   R   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   cbLoggedOut?  s    s	   127.0.0.1(   R   R   t   AvatarR  R  R   R  R   RA   R   R  R   R  R   R  R   R   R  R  R  (   R   R  RI   R   R  R  R  (    (   R   R  s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_logoutAfterDecref!  s     	
	c            s     j  j t j d d d d   t j   } | j t j d d  d  } | j t j d d  d  } t	 | | g  } d   } | j
 |    f d   } | j
 |  | j
   j |  t j d   j |  }   j | j  | S(	   s   
        Two different correct login attempts can be made on the same root
        object at the same time and produce two different resulting avatars.
        Rq   R   t   bazt   quuxs   BRAINS!c         S   s.   |  \ } } t  | j d  | j d  g  S(   Nt   getAvatarId(   R   Rs   (   t   .0t   firstt   second(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  Y  s    	c            s0   |  \ } }   j  | d    j  | d  d  S(   NRq   R  (   R  (   R  R  R  (   R   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   cbAvatarIds^  s    	s	   127.0.0.1(   R   R  R   RA   R   R   R  R   R  R   R   R  R   R   R  R  R  (   R   RI   t
   firstLogint   secondLoginR   R  R  R  (    (   R   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_concurrentLoginJ  s"    			c            s     j  j t j d d   t j     j t j d d   }  j t j d d   }   j	 | t
    j	 | t
  t | | g  }    f d   } | j |  t j d   j   }   j | j  | S(   sz   
        Test that a login attempt with an invalid user or invalid password
        fails in the appropriate way.
        R   R  t
   nosuchusert	   wrongpassc            s5     j  t  }   j t |  d    j d    S(   Ni   (   t   flushLoggedErrorsR   R   R   R  R#   (   R  t   errors(   R   RI   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   cleanup{  s    s	   127.0.0.1(   R   R  R   RA   R   R   R  R   R  R  R   R   R   R   R   R  R  R  (   R   R  R  R   R  R  (    (   R   RI   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_badUsernamePasswordLogini  s    	c         C   s   |  j  j t j    t j   } | j t j   d  } d   } | j	 |  | j	 |  j
 d  | j	 |  j |  t j d |  j |  } |  j | j  | S(   s   
        Verify that a PB server using a portal configured with an checker which
        allows IAnonymous credentials can be logged into using IAnonymous
        credentials.
        s   BRAINS!c         S   s   |  j  d d  S(   NR   i{   (   Rs   (   Ru   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s    i{   s	   127.0.0.1(   R   R  R   t   AllowAnonymousAccessR   R   R  R   t	   AnonymousR   R  R  R   R   R  R  R  (   R   RI   R   R  R  (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_anonymousLogin  s    	c            s     j  j t j d d   t j     j t j   d  }   j	 | t
     f d   } | j |  t j d   j   }   j | j  | S(   sg   
        Verify that without an anonymous checker set up, anonymous login is
        rejected.
        R   R  s   BRAINS!c            s5     j  t  }   j t |  d    j d    S(   Ni   (   R  R   R   R   R  R#   (   R  R  (   R   RI   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s    s	   127.0.0.1(   R   R  R   RA   R   R   R  R   R  R  R   R   R   R   R  R  R  (   R   R   R  R  (    (   R   RI   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_anonymousLoginNotPermitted  s    	c         C   s   |  j  j t j    |  j  j t j d d   t j   } | j t j	   d  } d   } | j
 |  | j
 |  j d  | j
 |  j |  t j d |  j |  } |  j | j  | S(   s   
        Like L{test_anonymousLogin} but against a portal with a checker for
        both IAnonymous and IUsernamePassword.
        R   R  s   BRAINS!c         S   s   |  j  d d  S(   NR   i{   (   Rs   (   Ru   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s    i{   s	   127.0.0.1(   R   R  R   R  RA   R   R   R  R   R  R   R  R  R   R   R  R  R  (   R   RI   R   R  R  (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt'   test_anonymousLoginWithMultipleCheckers  s    		c         C   s   |  j  j t j    |  j  j t j d d   t j   } | j t j	 d d  d  } d   } | j
 |  | j
 |  j d  | j
 |  j |  t j d |  j |  } |  j | j  | S(   s   
        Like L{test_anonymousLoginWithMultipleCheckers} but check that
        username/password authentication works.
        R   R  s   BRAINS!c         S   s   |  j  d d d  S(   Nt   addid   i   (   Rs   (   Ru   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s    i{   s	   127.0.0.1(   R   R  R   R  RA   R   R   R  R   R  R   R  R  R   R   R  R  R  (   R   RI   R   R  R  (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt+   test_authenticatedLoginWithMultipleCheckers  s    		c         C   s   |  j  j t j d d   t j   } | j t j d d  d  } d   } | j	 |  d   } | j	 |  | j	 |  j
  | j	 |  j |  t j d |  j |  } |  j | j  | S(   sb   
        Verify that a viewpoint can be retrieved after authenticating with
        cred.
        R   R  s   BRAINS!c         S   s   |  j  d  S(   Nt   getViewPoint(   Rs   (   Ru   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s    c         S   s   |  j  d  S(   NR   (   Rs   (   t	   viewpoint(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   cbView  s    s	   127.0.0.1(   R   R  R   RA   R   R   R  R   R  R   R   R  R   R   R  R  R  (   R   RI   R   R  R  R  (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	   test_view  s    			(   R   R   R!   R   R   R   R   R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  `  s&   					(	
			!	)						t   NonSubclassingPerspectivec           B   s0   e  Z e e j  d    Z d   Z d   Z RS(   c         C   s   d  S(   N(    (   R   R&   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR1     s    c         C   s:   | j  | |   } | j  | |   } | j | | | f  S(   N(   t   unserializet	   serialize(   R   R   t   messageR8  t   kwargs(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   perspectiveMessageReceived  s    c         C   s   t  |  _ d  S(   N(   R  R  (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s    (   R   R   R   R   R%   R1   R  R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s   		t   NSPTestCasec           B   s    e  Z d  Z d   Z d   Z RS(   s   
    Tests for authentication against a realm where the L{IPerspective}
    implementation is not a subclass of L{Avatar}.
    c         C   s   t    |  _ t |  j _ t j |  j  |  _ t j   |  _ |  j j	 d d  |  j j
 |  j  t t j |  j   |  _ t j d |  j d d |  _ |  j |  j j  |  j j   j |  _ d  S(   NR   R  i    R  s	   127.0.0.1(   R  R  R  R  R   RC   R   RA   RH   t   addUserR  R   R   RB   RI   R   R   R   R  R   R   R  (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR     s    c            s   t  j     j t j d d  d  } t j d   j   | j d    | j   j	 d d i d d	 6f     f d
   } | j |  | S(   s   
        An L{IPerspective} implementation which does not subclass
        L{Avatar} can expose remote methods for the client to call.
        R   R  s   BRAINS!s	   127.0.0.1c         S   s   |  j  d d d d S(   Nt   ANYTHINGt   hereR   R  (   Rs   (   Rx  (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR$   .  s    R  R  R  R   c            s2    j    x!   j j D] } | j j   q Wd  S(   N(   R  RI   R   R9   R   (   R  Rx  (   R   RI   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  1  s    
(   s   here(
   R   R   R  R   R  R   R   R  R   R   (   R   R   R  (    (   R   RI   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_NSP%  s    	(   R   R   R!   R   R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s   	t
   IForwardedc           B   s    e  Z d  Z d   Z d   Z RS(   sA   
    Interface used for testing L{util.LocalAsyncForwarder}.
    c           C   s   d S(   s,   
        Simple synchronous method.
        N(    (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	   forwardMe?  s    c           C   s   d S(   s-   
        Simple asynchronous method.
        N(    (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   forwardDeferredD  s    (   R   R   R!   R  R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  :  s   	t	   Forwardedc           B   s?   e  Z d  Z e e  e Z e Z d   Z d   Z	 d   Z
 RS(   s   
    Test implementation of L{IForwarded}.

    @ivar forwarded: set if C{forwardMe} is called.
    @type forwarded: C{bool}
    @ivar unforwarded: set if C{dontForwardMe} is called.
    @type unforwarded: C{bool}
    c         C   s   t  |  _ d S(   s6   
        Set a local flag to test afterwards.
        N(   R  t	   forwarded(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  W  s    c         C   s   t  |  _ d S(   sv   
        Set a local flag to test afterwards. This should not be called as it's
        not in the interface.
        N(   R  t   unforwarded(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   dontForwardMe]  s    c         C   s
   t  t  S(   s0   
        Asynchronously return C{True}.
        (   R   R  (   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  d  s    (   R   R   R!   R   R  R  R  R  R  R  R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  J  s   
		t   SpreadUtilTestCasec           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s+   
    Tests for L{twisted.spread.util}.
    c         C   s)   t    } |  j | j d d  d  d S(   sk   
        Call a synchronous method of a L{util.LocalAsRemote} object and check
        the result.
        t   add1i   i   N(   R|  R   Rs   (   R   Rf  (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt	   test_syncp  s    	c         C   sQ   t    } t    } | j d d d d } |  j | t  | j |  j d  | S(   sm   
        Call an asynchronous method of a L{util.LocalAsRemote} object and check
        the result.
        R  i   RZ   i   i   (   R|  Rs   R  R   R   R   (   R   Rf  R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt
   test_asyncx  s    		c            sD   t    } | j d  }   f d   } | j   f d   |  | S(   sF   
        Test a asynchronous failure on a remote method call.
        R   c            s*     j  t |  t j   |  j t  d  S(   N(   R   R   R   Rs  t   trapRa   (   t   f(   R   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   eb  s    c            s     j  d  S(   Ns   supposed to fail(   R   (   R   (   R   (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR$     s    (   R|  Rs   R   (   R   Rf  R   R  (    (   R   s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_asyncFail  s
    	c         C   s2   t    } | j d  } |  j | d  d  d S(   sM   
        Test the C{remoteMethod} facility of L{util.LocalAsRemote}.
        R  i   i   N(   R|  R   R   (   R   Rf  t   m(    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_remoteMethod  s    	c         C   s   t    } t j | t  } | j d  |  j | j  | j d  |  j | j  | j d  } g  } | j	 | j
  |  j | d d  d S(   se   
        Test a call to L{util.LocalAsyncForwarder} using L{Forwarded} local
        object.
        R  R  R  i    i   N(   R  R   t   LocalAsyncForwarderR  Rs   R   R  R	  R  R   R   R  (   R   R  t   lft   rrR   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_localAsyncForwarder  s    	(   R   R   R!   R  R  R  R  R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR  k  s   				t   PBWithSecurityOptionsTestc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s&   
    Test security customization.
    c         C   s5   t  j   } | j d  } |  j | j t j  d S(   sl   
        By default, client broker should use C{jelly.globalSecurity} as
        security settings.
        N(   R   R   RD   R#   R   t   securityR   t   globalSecurity(   R   RI   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt!   test_clientDefaultSecurityOptions  s    c         C   s;   t  j t    } | j d  } |  j | j t j  d S(   sl   
        By default, server broker should use C{jelly.globalSecurity} as
        security settings.
        N(	   R   RB   R   RD   R#   R   R  R   R  (   R   RI   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt!   test_serverDefaultSecurityOptions  s    c         C   sD   t  j   } t j d |  } | j d  } |  j | j |  d S(   ss   
        Check that the security settings are passed from the client factory to
        the broker object.
        R  N(   R   t   SecurityOptionsR   R   RD   R#   R   R  (   R   R  RI   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt    test_clientSecurityCustomization  s    c         C   sJ   t  j   } t j t   d | } | j d  } |  j | j |  d S(   ss   
        Check that the security settings are passed from the server factory to
        the broker object.
        R  N(	   R   R  R   RB   R   RD   R#   R   R  (   R   R  RI   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt    test_serverSecurityCustomization  s    (   R   R   R!   R  R  R	  R
  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s
   	
	
	t   DeprecationTestsc           B   s    e  Z d  Z d   Z d   Z RS(   sS   
    Tests for certain deprecations of free-functions in L{twisted.spread.pb}.
    c      	   C   s8   |  j  t d d d d  t j d d d d d d	 d
 S(   s2   
        L{pb.noOperation} is deprecated.
        t   twistedi   i   i    i   RY   i   RZ   i   N(   t   callDeprecatedR   R   t   noOperation(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_noOperationDeprecated  s    c         C   s)   |  j  t d d d d  t j d  d S(   s5   
        L{pb.printTraceback} is deprecated.
        R  i   i   i    s/   printTraceback deprecation fake traceback valueN(   R  R   R   t   printTraceback(   R   (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   test_printTraceback  s    (   R   R   R!   R  R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyR    s   		(s   R!   R  R   R2   R  t	   cStringIOR    t   zope.interfaceR   R   t   twisted.python.versionsR   t   twisted.trialR   t   twisted.spreadR   R   R   R   t   twisted.internetR	   R
   R   t   twisted.internet.errorR   t   twisted.internet.deferR   R   R   t   twisted.protocols.policiesR   t   twisted.pythonR   R   t   twisted.cred.errorR   R   t   twisted.credR   R   R   t   ViewableR   R  R   R   R"   R,   RM   R   RN   RS   t   CopyableRU   t
   RemoteCopyR\   t   setUnjellyableForClassR]   Rf   t   setUnjellyableFactoryForClassRg   t	   CacheableRk   Rm   Rn   t   RemoteCacheRz   R~   R   R   R   R   R   R   R   t   RootR   R   t   TestCaseR   RB   R   R   R   R=  R#   R6  R7  R:  R;  R@  RE  t   PublishableRZ  t   RemotePublishedR\  R(  Ra  RQ   Rw  Rj  Ri  t   LocalAsRemoteR|  R  R  R  R  R  R  R  R  R  R  R  (    (    (    s8   /usr/lib/python2.7/dist-packages/twisted/test/test_pb.pyt   <module>	   s   0"		1					"""@!+ 
	
rD)# '!?0