+
    Dfj                     (   R t ^ RIHtHtHtHt ^ RIHtHt ^ RI	H
t
 ^ RIHt ^ RIHt  ! R R]P                  4      t ! R R	]P"                  4      t ! R
 R]P&                  4      t ! R R]P                  4      t ! R R]P                  4      tR# )z+
Test cases for twisted.protocols package.
)addressdeferprotocolreactor)portforwardwire)	iterbytes)proto_helpers)unittestc                   <   a  ] tR t^t o RtR tR tR tR tRt	V t
R# )	WireTestsz
Test wire protocols.
c                f   \         P                  ! 4       p\        P                  ! 4       pVP	                  V4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       V P                  VP                  4       R4       R# )zD
Test wire.Echo protocol: send some data and check it send it back.
   hello   world   how   are   yous   helloworldhowareyouN)r	   StringTransportr   EchomakeConnectiondataReceivedassertEqualvalueselftas   &  =/usr/lib/python3/dist-packages/twisted/test/test_protocols.py	test_echoWireTests.test_echo   s~     ))+IIK		x 	x 	v	v	v$:;    c                    \         P                  ! 4       p\        P                  ! 4       pVP	                  V4       V P                  VP                  4       R4       R# )z
Test wire.Who protocol.
s   root
N)r	   r   r   Whor   r   r   r   s   &  r   test_whoWireTests.test_who"   sA     ))+HHJ	K0r    c                    \         P                  ! 4       p\        P                  ! 4       pVP	                  V4       V P                  VP                  4       R4       R# )z
Test wire.QOTD protocol.
s'   An apple a day keeps the doctor away.
N)r	   r   r   QOTDr   r   r   r   s   &  r   	test_QOTDWireTests.test_QOTD+   sB     ))+IIK	$PQr    c                f   \         P                  ! 4       p\        P                  ! 4       pVP	                  V4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       V P                  VP                  4       R4       R# )z
Test wire.Discard protocol.
r   r   r   r   r   r    N)r	   r   r   Discardr   r   r   r   r   s   &  r   test_discardWireTests.test_discard4   s}     ))+LLN		x 	x 	v	v	vC(r     N)__name__
__module____qualname____firstlineno____doc__r   r#   r'   r+   __static_attributes____classdictcell____classdict__s   @r   r   r      s$     <1R) )r    r   c                   *   a  ] tR t^Ct o RtR tRtV tR# )TestableProxyClientFactoryz
Test proxy client factory that keeps the last created protocol instance.

@ivar protoInstance: the last instance of the protocol.
@type protoInstance: L{portforward.ProxyClient}
c                P    \         P                  P                  W4      pW n        V# )z5
Create the protocol instance and keeps track of it.
)r   ProxyClientFactorybuildProtocolprotoInstancer   addrprotos   && r   r;   (TestableProxyClientFactory.buildProtocolK   s%     ..<<TH"r    )r<   Nr.   r/   r0   r1   r2   r;   r3   r4   r5   s   @r   r8   r8   C   s      r    r8   c                   *   a  ] tR t^Tt o RtR tRtV tR# )TestableProxyFactoryaP  
Test proxy factory that keeps the last created protocol instance.

@ivar protoInstance: the last instance of the protocol.
@type protoInstance: L{portforward.ProxyServer}

@ivar clientFactoryInstance: client factory used by C{protoInstance} to
    create forward connections.
@type clientFactoryInstance: L{TestableProxyClientFactory}
c                   a  \         P                  P                  S V4      p\        4       S n        V 3R lVn        VS n        V# )zo
Create the protocol instance, keeps track of it, and makes it use
C{clientFactoryInstance} as client factory.
c                     < S P                   # N)clientFactoryInstancer   s   r   <lambda>4TestableProxyFactory.buildProtocol.<locals>.<lambda>h   s    d.H.Hr    )r   ProxyFactoryr;   r8   rG   clientProtocolFactoryr<   r=   s   f& r   r;   "TestableProxyFactory.buildProtocol`   s=    
 ((66tTB%?%A"&H#"r    )rG   r<   NrA   r5   s   @r   rC   rC   T   s     	
 
r    rC   c                   <   a  ] tR t^mt o RtR tR tR tR tRt	V t
R# )PortforwardingTestsz
Test port forwarding.
c                |    \         P                  ! 4       V n        \        P                  ! 4       V n        . V n        R # rF   )r   r   serverProtocolr   ProtocolclientProtocol	openPortsrH   s   &r   setUpPortforwardingTests.setUpr   s(    "iik&//1r    c                    V P                   P                  P                  P                  4         V P                   P
                  P                  pVP                  P                  4         V P                  P                  P                  4         V P                  P                  P                  4        \        P                  ! V P                   Uu. uF#  p\        P                  ! VP                  4      NK%  	  up4      #   \         d     Li ; i  \         d     Li ; i  \         d     Li ; i  \         d     Li ; iu upi rF   )proxyServerFactoryr<   	transportloseConnectionAttributeErrorrG   rS   rQ   r   gatherResultsrT   maybeDeferredstopListening)r   pips   &  r   tearDownPortforwardingTests.tearDownw   s   	##11;;JJL	((>>LLBLL'')	))88:	))88: "";?>>J>aU  1>J
 	
  		
  		  		  		 KsL   .D :D ,$D% $D6 )EDDD"!D"%D32D36EEc                  a aaa	 \         P                  ! 4       pV 3R lVn         \        P                  ! ^ VRR7      pS P                  P                  V4       \        RVP                  4       P                  4      S n	        \        P                  ! ^ S P                  RR7      pS P                  P                  V4       Ro. o	\        P                  ! 4       oVVV	V 3R lpVS P                  n        VV 3R lpVS P                  n        \         P                  ! 4       pV 3R lVn         \        P                   ! RVP                  4       P                  V4       S# )z-
Test port forwarding through Echo protocol.
c                     < S P                   # rF   )rQ   rH   s   r   rI   6PortforwardingTests.test_portforward.<locals>.<lambda>   s    T-@-@r    	127.0.0.1)	interfacei  c                    < SP                  \        V 4      4       \        S4      S8  d<   SP                  R P	                  S4      RS,          4       SP                  R4       R# R# )r       xN)extendr   lenr   joincallback)datadnBytesreceivedr   s   &r   testDataReceived>PortforwardingTests.test_portforward.<locals>.testDataReceived   sM    OOIdO,8}&  (!3TF]C

4  'r    c                  `   < SP                   P                  P                  R S ,          4       R# )ri   N)rS   rY   write)rp   r   s   r   testConnectionMade@PortforwardingTests.test_portforward.<locals>.testConnectionMade   s!    ))//v>r    c                     < S P                   # rF   )rS   rH   s   r   rI   re      s    )<)<r    )r   ServerFactoryr   	listenTCPrT   appendrC   getHostportrX   r   DeferredrS   r   connectionMadeClientFactory
connectTCP)
r   realServerFactoryrealServerPortproxyServerPortrr   rv   clientFactoryro   rp   rq   s
   f      @@@r   test_portforward$PortforwardingTests.test_portforward   s    %224%@" **1.?;Wn-"6//166#
 "++t&&+
 	o.NN	! 	! ,<(	? .@* ..0!<;(?(?(A(F(FVr    c                   \         P                  ! RR^ 4      p\        P                  ! R^ 4      P	                  V4      p\
        P                  ! 4       pW2n        \
        P                  ! 4       pVP                  V4       V P                  \        VP                  4      ^4       VP                  ^ ,          w  rVrxp	V P                  V\        P                  4       VP	                  V4      p
\
        P                  ! 4       pV
P                  V4       V P                  VP                   V4       V P                  VP                   V4       V P#                  VP$                  4       V P#                  VP$                  4       R# )zU
The proxy client registers itself as a producer of the proxy server and
vice versa.
TCPrf   N)r   IPv4Addressr   rK   r;   r	   MemoryReactorr   r   r   r   rk   
tcpClientsassertIsInstancer:   assertIsproducer
assertTrue	streaming)r   r>   serverr   serverTransporthostr}   r   timeout_clientclientTransports   &           r   test_registerProducers*PortforwardingTests.test_registerProducers   s.    ""5+q9))+q9GGM  --/  (779o. 	W//0!4070B0B10E-MAm[-K-KL ,,T2'779o. 	o..@o..@112112r    )rS   rT   rX   rQ   N)r.   r/   r0   r1   r2   rU   ra   r   r   r3   r4   r5   s   @r   rO   rO   m   s$     

,&P!3 !3r    rO   c                   *   a  ] tR t^t o RtR tRtV tR# )StringTransportTestsz9
Test L{proto_helpers.StringTransport} helper behaviour.
c                r    \         P                  ! 4       pV P                  \        VP                  R4       R# )zI
Test that L{proto_helpers.StringTransport} doesn't accept unicode data.
fooN)r	   r   assertRaises	TypeErrorru   )r   ss   & r   test_noUnicode#StringTransportTests.test_noUnicode   s(     ))+)QWWe4r    r-   N)r.   r/   r0   r1   r2   r   r3   r4   r5   s   @r   r   r      s     5 5r    r   N)r2   twisted.internetr   r   r   r   twisted.protocolsr   r   twisted.python.compatr   twisted.testr	   twisted.trialr
   TestCaser   r:   r8   rK   rC   rO   r   r-   r    r   <module>r      s|    ? > / + & "1)!! 1)h!?!? ";33 2i3(++ i3X
58,, 
5r    