+
    üÐjVH  ã                   ó  € R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
HtHtHt ^ RIHtHtHtHtHtHt ^ RIHtHt ^ RIHtHt ^ R	IHt ^ R
IHt  ! R R]4      t ! R R]4      t  ! R R]4      t! ! R R]4      t" ! R R]4      t#R# )z)
Tests for L{twisted.internet.protocol}.
)ÚBytesIO)Úimplementer)ÚverifyObject)ÚCancelledError)Ú	IConsumerÚILoggingContextÚ	IProtocolÚIProtocolFactory)ÚClientCreatorÚConsumerToProtocolAdapterÚFactoryÚFileWrapperÚProtocolÚProtocolToConsumerAdapter)ÚMemoryReactorClockÚStringTransport)ÚLogLevelÚglobalLogPublisher)ÚFailure)ÚTestCasec                   ó„   a € ] tR t^#t o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tR tRtV tR# )ÚClientCreatorTestsz7
Tests for L{twisted.internet.protocol.ClientCreator}.
c                ó¢   €  ! R R\         4      p\        4       p\        W24      pV! W44      pVP                  R4      pV P	                  Wb4       R# )aÖ  
Helper for implementing a test to verify that one of the I{connect}
methods of L{ClientCreator} passes the right arguments to the right
reactor method.

@param check: A function which will be invoked with a reactor and a
    L{ClientCreator} instance and which should call one of the
    L{ClientCreator}'s I{connect} methods and assert that all of its
    arguments except for the factory are passed on as expected to the
    reactor.  The factory should be returned.
c                   ó   € ] tR t^5tRtR# )Ú:ClientCreatorTests._basicConnectTest.<locals>.SomeProtocol© N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    ÚE/usr/lib/python3/dist-packages/twisted/internet/test/test_protocol.pyÚSomeProtocolr   5   ó   † Ûr"   r$   N)r   r   r
   ÚbuildProtocolÚassertIsInstance)ÚselfÚcheckr$   ÚreactorÚccÚfactoryÚprotocols   &&     r#   Ú_basicConnectTestÚ$ClientCreatorTests._basicConnectTest(   sJ   € ô	œ8ô 	ô %Ó&ˆÜ˜7Ó1ˆÙ˜Ó$ˆØ×(Ñ(¨Ó.ˆØ×Ñ˜hÖ5r"   c                ó6   a € V 3R lpS P                  V4       R# )zÄ
L{ClientCreator.connectTCP} calls C{reactor.connectTCP} with the host
and port information passed to it, and with a factory which will
construct the protocol passed to L{ClientCreator.__init__}.
c                 óü   <€ VP                  R RRR4       V P                  P                  4       w  r#rEpSP                  VR 4       SP                  VR4       SP                  VR4       SP                  VR4       V# )úexample.coméÒ  éá  )z1.2.3.4i”&  )Ú
connectTCPÚ
tcpClientsÚpopÚassertEqual)r*   r+   ÚhostÚportr,   ÚtimeoutÚbindAddressr(   s   &&     €r#   r)   Ú1ClientCreatorTests.test_connectTCP.<locals>.checkE   sw   ø€ Ø�M‰M˜-¨¨tÐ5FÔGØ8?×8JÑ8J×8NÑ8NÓ8PÑ5ˆD˜¨+Ø×Ñ˜T =Ô1Ø×Ñ˜T 4Ô(Ø×Ñ˜W dÔ+Ø×Ñ˜[Ð*;Ô<ØˆNr"   N©r.   ©r(   r)   s   f r#   Útest_connectTCPÚ"ClientCreatorTests.test_connectTCP>   s   ø€ õ	ð 	×Ñ˜uÖ%r"   c                ó6   a € V 3R lpS P                  V4       R# )zµ
L{ClientCreator.connectUNIX} calls C{reactor.connectUNIX} with the
filename passed to it, and with a factory which will construct the
protocol passed to L{ClientCreator.__init__}.
c                 óÒ   <€ VP                  R ^{R4       V P                  P                  4       w  r#rESP                  VR 4       SP                  V^{4       SP	                  V4       V# )ú/foo/barT)ÚconnectUNIXÚunixClientsr7   r8   Ú
assertTrue)r*   r+   Úaddressr,   r;   ÚcheckPIDr(   s   &&    €r#   r)   Ú2ClientCreatorTests.test_connectUNIX.<locals>.checkW   s]   ø€ Ø�N‰N˜: s¨DÔ1Ø29×2EÑ2E×2IÑ2IÓ2KÑ/ˆG˜gØ×Ñ˜W jÔ1Ø×Ñ˜W cÔ*Ø�O‰O˜HÔ%ØˆNr"   Nr>   r?   s   f r#   Útest_connectUNIXÚ#ClientCreatorTests.test_connectUNIXP   s   ø€ õ	ð 	×Ñ˜uÖ%r"   c                ó6   a € V 3R lpS P                  V4       R# )zÊ
L{ClientCreator.connectSSL} calls C{reactor.connectSSL} with the host,
port, and context factory passed to it, and with a factory which will
construct the protocol passed to L{ClientCreator.__init__}.
c                 ó:  <€ \        4       pVP                  R RVRR4       V P                  P                  4       w  ppppppS	P	                  VR 4       S	P	                  VR4       S	P                  Wb4       S	P	                  VR4       S	P	                  VR4       V# )r2   r3   r4   )z4.3.2.1i.  )ÚobjectÚ
connectSSLÚ
sslClientsr7   r8   ÚassertIs)
r*   r+   ÚexpectedContextFactoryr9   r:   r,   ÚcontextFactoryr;   r<   r(   s
   &&       €r#   r)   Ú1ClientCreatorTests.test_connectSSL.<locals>.checkh   s¡   ø€ Ü%+£XÐ"Ø�M‰MØ˜tÐ%;¸TÐCTôð ×"Ñ"×&Ñ&Ó(ñØØØØØØà×Ñ˜T =Ô1Ø×Ñ˜T 4Ô(Ø�M‰M˜.ÔAØ×Ñ˜W dÔ+Ø×Ñ˜[Ð*;Ô<ØˆNr"   Nr>   r?   s   f r#   Útest_connectSSLÚ"ClientCreatorTests.test_connectSSLa   s   ø€ õ	ð( 	×Ñ˜uÖ%r"   c                ó2  € \        4       p\        V\        4      pV! V4      pVP                  P	                  4       pV P                  VP                  4       VP                  4        V P                  VP                  4       V P                  V\        4      # )aÏ  
Helper for implementing a test to verify that cancellation of the
L{Deferred} returned by one of L{ClientCreator}'s I{connect} methods is
implemented to cancel the underlying connector.

@param connect: A function which will be invoked with a L{ClientCreator}
    instance as an argument and which should call one its I{connect}
    methods and return the result.

@return: A L{Deferred} which fires when the test is complete or fails if
    there is a problem.
)r   r
   r   Ú
connectorsr7   ÚassertFalseÚ_disconnectedÚcancelrG   ÚassertFailurer   ©r(   Úconnectr*   r+   ÚdÚ	connectors   &&    r#   Ú_cancelConnectTestÚ%ClientCreatorTests._cancelConnectTest~   sw   € ô %Ó&ˆÜ˜7¤HÓ-ˆÙ�B‹KˆØ×&Ñ&×*Ñ*Ó,ˆ	Ø×Ñ˜×0Ñ0Ô1Ø	�‰Œ
Ø�‰˜	×/Ñ/Ô0Ø×!Ñ! !¤^Ó4Ð4r"   c                ó*   € R pV P                  V4      # )ú
The L{Deferred} returned by L{ClientCreator.connectTCP} can be cancelled
to abort the connection attempt before it completes.
c                 ó&   € V P                  R R4      # ©r2   r3   )r5   ©r+   s   &r#   r_   Ú9ClientCreatorTests.test_cancelConnectTCP.<locals>.connectš   s   € Ø—=‘= °Ó5Ð5r"   ©rb   ©r(   r_   s   & r#   Útest_cancelConnectTCPÚ(ClientCreatorTests.test_cancelConnectTCP”   s   € ò	6ð ×&Ñ& wÓ/Ð/r"   c                ó*   € R pV P                  V4      # )re   c                 ó$   € V P                  R 4      # ©rD   )rE   rh   s   &r#   r_   Ú:ClientCreatorTests.test_cancelConnectUNIX.<locals>.connect¥   s   € Ø—>‘> *Ó-Ð-r"   rj   rk   s   & r#   Útest_cancelConnectUNIXÚ)ClientCreatorTests.test_cancelConnectUNIXŸ   s   € ò	.ð ×&Ñ& wÓ/Ð/r"   c                ó*   € R pV P                  V4      # )re   c                 ó8   € V P                  R R\        4       4      # rg   )rP   rO   rh   s   &r#   r_   Ú9ClientCreatorTests.test_cancelConnectSSL.<locals>.connect°   s   € Ø—=‘= °´f³hÓ?Ð?r"   rj   rk   s   & r#   Útest_cancelConnectSSLÚ(ClientCreatorTests.test_cancelConnectSSLª   s   € ò	@ð ×&Ñ& wÓ/Ð/r"   c                óŽ  € \        4       p\        V\        4      pV! W#4      pVP                  P	                  4       pV P                  \        VP                  4       4      ^4       VP                  4        V P                  VP                  4       . 4       V P                  VP                  4       V P                  V\        4      # )z­
Like L{_cancelConnectTest}, but for the case where the L{Deferred} is
cancelled after the connection is set up but before it is fired with the
resulting protocol instance.
)r   r
   r   rY   r7   r8   ÚlenÚgetDelayedCallsr\   rG   r[   r]   r   r^   s   &&    r#   Ú_cancelConnectTimeoutTestÚ,ClientCreatorTests._cancelConnectTimeoutTestµ   s¡   € ô %Ó&ˆÜ˜7¤HÓ-ˆÙ�GÓ ˆØ×&Ñ&×*Ñ*Ó,ˆ	ð 	×Ñœ˜W×4Ñ4Ó6Ó7¸Ô;ð 	
�‰Œ
à×Ñ˜×0Ñ0Ó2°BÔ7ð
 	�‰˜	×/Ñ/Ô0à×!Ñ! !¤^Ó4Ð4r"   c                ó*   € R pV P                  V4      # )ai  
L{ClientCreator.connectTCP} inserts a very short delayed call between
the time the connection is established and the time the L{Deferred}
returned from one of its connect methods actually fires.  If the
L{Deferred} is cancelled in this interval, the established connection is
closed, the timeout is cancelled, and the L{Deferred} fails with
L{CancelledError}.
c                 ó¾   € VP                  R R4      pV P                  P                  4       w  r4rVpVP                  R4      p\	        4       p	VP                  V	4       V# ©r2   r3   N)r5   r6   r7   r&   r   ÚmakeConnection)
r*   r+   r`   r9   r:   r,   r;   r<   r-   Ú	transports
   &&        r#   r_   Ú@ClientCreatorTests.test_cancelConnectTCPTimeout.<locals>.connectÚ   sX   € Ø—‘˜m¨TÓ2ˆAØ8?×8JÑ8J×8NÑ8NÓ8PÑ5ˆD˜¨+Ø×,Ñ,¨TÓ2ˆHÜ'Ó)ˆIØ×#Ñ# IÔ.ØˆHr"   ©r|   rk   s   & r#   Útest_cancelConnectTCPTimeoutÚ/ClientCreatorTests.test_cancelConnectTCPTimeoutÐ   ó   € ò	ð ×-Ñ-¨gÓ6Ð6r"   c                ó*   € R pV P                  V4      # )aj  
L{ClientCreator.connectUNIX} inserts a very short delayed call between
the time the connection is established and the time the L{Deferred}
returned from one of its connect methods actually fires.  If the
L{Deferred} is cancelled in this interval, the established connection is
closed, the timeout is cancelled, and the L{Deferred} fails with
L{CancelledError}.
c                 óº   € VP                  R 4      pV P                  P                  4       w  r4rVVP                  R4      p\	        4       pVP                  V4       V# )rD   N)rE   rF   r7   r&   r   r�   )	r*   r+   r`   rH   r,   r;   r<   r-   r‚   s	   &&       r#   r_   ÚAClientCreatorTests.test_cancelConnectUNIXTimeout.<locals>.connectî   sT   € Ø—‘˜zÓ*ˆAØ5<×5HÑ5H×5LÑ5LÓ5NÑ2ˆG˜gØ×,Ñ,¨TÓ2ˆHÜ'Ó)ˆIØ×#Ñ# IÔ.ØˆHr"   r„   rk   s   & r#   Útest_cancelConnectUNIXTimeoutÚ0ClientCreatorTests.test_cancelConnectUNIXTimeoutä   r‡   r"   c                ó*   € R pV P                  V4      # )ai  
L{ClientCreator.connectSSL} inserts a very short delayed call between
the time the connection is established and the time the L{Deferred}
returned from one of its connect methods actually fires.  If the
L{Deferred} is cancelled in this interval, the established connection is
closed, the timeout is cancelled, and the L{Deferred} fails with
L{CancelledError}.
c                 óÖ   € VP                  R R\        4       4      pV P                  P                  4       w  ppppppVP	                  R4      p	\        4       p
V	P                  V
4       V# r€   )rP   rO   rQ   r7   r&   r   r�   )r*   r+   r`   r9   r:   r,   rT   r;   ÚbindADdressr-   r‚   s   &&         r#   r_   Ú@ClientCreatorTests.test_cancelConnectSSLTimeout.<locals>.connect  sl   € Ø—‘˜m¨T´6³8Ó<ˆAð ×"Ñ"×&Ñ&Ó(ñØØØØØØà×,Ñ,¨TÓ2ˆHÜ'Ó)ˆIØ×#Ñ# IÔ.ØˆHr"   r„   rk   s   & r#   Útest_cancelConnectSSLTimeoutÚ/ClientCreatorTests.test_cancelConnectSSLTimeoutø   s   € ò	ð ×-Ñ-¨gÓ6Ð6r"   c                ó¤  € \        4       p\        V\        4      pV! W#4      w  rEVP                  P	                  4       pVP                  V\        \        R4      4      4       V P                  \        VP                  4       4      ^4       VP                  4        V P                  VP                  4       . 4       V P                  V\        4      # )z¬
Like L{_cancelConnectTest}, but for the case where the L{Deferred} is
cancelled after the connection attempt has failed but before it is fired
with the resulting failure.
zSimulated failure)r   r
   r   rY   r7   ÚclientConnectionFailedr   Ú	Exceptionr8   rz   r{   r\   r]   r   )r(   r_   r*   r+   r`   r,   ra   s   &&     r#   Ú_cancelConnectFailedTimeoutTestÚ2ClientCreatorTests._cancelConnectFailedTimeoutTest  s­   € ô %Ó&ˆÜ˜7¤HÓ-ˆÙ˜WÓ)‰
ˆØ×&Ñ&×*Ñ*Ó,ˆ	Ø×&Ñ&Ø”wœyÐ)<Ó=Ó>ô	
ð 	×Ñœ˜W×4Ñ4Ó6Ó7¸Ô;ð 	
�‰Œ
à×Ñ˜×0Ñ0Ó2°BÔ7à×!Ñ! !¤^Ó4Ð4r"   c                ó*   € R pV P                  V4      # )zb
Similar to L{test_cancelConnectTCPTimeout}, but for the case where the
connection attempt fails.
c                 óh   € VP                  R R4      pV P                  P                  4       w  r4rVpW%3# rg   )r5   r6   r7   )r*   r+   r`   r9   r:   r,   r;   r<   s   &&      r#   r_   ÚFClientCreatorTests.test_cancelConnectTCPFailedTimeout.<locals>.connect2  s5   € Ø—‘˜m¨TÓ2ˆAØ8?×8JÑ8J×8NÑ8NÓ8PÑ5ˆD˜¨+Ø�:Ðr"   ©r–   rk   s   & r#   Ú"test_cancelConnectTCPFailedTimeoutÚ5ClientCreatorTests.test_cancelConnectTCPFailedTimeout,  ó   € ò	ð
 ×3Ñ3°GÓ<Ð<r"   c                ó*   € R pV P                  V4      # )zc
Similar to L{test_cancelConnectUNIXTimeout}, but for the case where the
connection attempt fails.
c                 ód   € VP                  R 4      pV P                  P                  4       w  r4rVW$3# rp   )rE   rF   r7   )r*   r+   r`   rH   r,   r;   r<   s   &&     r#   r_   ÚGClientCreatorTests.test_cancelConnectUNIXFailedTimeout.<locals>.connect?  s1   € Ø—‘˜zÓ*ˆAØ5<×5HÑ5H×5LÑ5LÓ5NÑ2ˆG˜gØ�:Ðr"   r›   rk   s   & r#   Ú#test_cancelConnectUNIXFailedTimeoutÚ6ClientCreatorTests.test_cancelConnectUNIXFailedTimeout9  rž   r"   c                ó*   € R pV P                  V4      # )zb
Similar to L{test_cancelConnectSSLTimeout}, but for the case where the
connection attempt fails.
c                 ó€   € VP                  R R\        4       4      pV P                  P                  4       w  ppppppW%3# rg   )rP   rO   rQ   r7   )	r*   r+   r`   r9   r:   r,   rT   r;   r�   s	   &&       r#   r_   ÚFClientCreatorTests.test_cancelConnectSSLFailedTimeout.<locals>.connectL  sI   € Ø—‘˜m¨T´6³8Ó<ˆAð ×"Ñ"×&Ñ&Ó(ñØØØØØØà�:Ðr"   r›   rk   s   & r#   Ú"test_cancelConnectSSLFailedTimeoutÚ5ClientCreatorTests.test_cancelConnectSSLFailedTimeoutF  s   € ò
	ð ×3Ñ3°GÓ<Ð<r"   r   N)r   r   r   r    Ú__doc__r.   r@   rK   rV   rb   rl   rr   rw   r|   r…   r‹   r‘   r–   rœ   r¢   r§   r!   Ú__classdictcell__©Ú__classdict__s   @r#   r   r   #   s_   ø‡ € ñò6ò,&ò$&ò"&ò:5ò,	0ò	0ò	0ò5ò67ò(7ò(7ò65ò2=ò=÷=ð =r"   r   c                   ó6   a € ] tR tRt o RtR tR tR tRtV t	R# )ÚProtocolTestsi[  z2
Tests for L{twisted.internet.protocol.Protocol}.
c                ó–   € \        4       pV P                  \        \        V4      4       V P                  \        \        V4      4       R# )zD
L{Protocol} instances provide L{IProtocol} and L{ILoggingContext}.
N)r   rG   r   r   r   )r(   Úprotos   & r#   Útest_interfacesÚProtocolTests.test_interfaces`  s1   € ô “
ˆØ�‰œ¤Y°Ó6Ô7Ø�‰œ¤_°eÓ<Ö=r"   c                ón   €  ! R R\         4      pV P                  RV! 4       P                  4       4       R# )z:
L{Protocol.logPrefix} returns the protocol class's name.
c                   ó   € ] tR tRtRtR# )Ú/ProtocolTests.test_logPrefix.<locals>.SomeThingim  r   Nr   r   r"   r#   Ú	SomeThingrµ   m  r%   r"   r¶   N)r   r8   Ú	logPrefix)r(   r¶   s   & r#   Útest_logPrefixÚProtocolTests.test_logPrefixh  s+   € ô
	œô 	ð 	×Ñ˜¡i£k×&;Ñ&;Ó&=Ö>r"   c                óš   a€ . o ! V3R lR\         4      p\        4       pV! 4       pVP                  V4       V P                  SV.4       R# )zb
L{Protocol.makeConnection} sets the given transport on itself, and
then calls C{connectionMade}.
c                   ó.   <a € ] tR tRt o V3R ltRtV tR# )Ú7ProtocolTests.test_makeConnection.<locals>.SomeProtocoliy  c                ó>   <€ SP                  V P                  4       R # ©N)Úappendr‚   )r(   Úresults   &€r#   ÚconnectionMadeÚFProtocolTests.test_makeConnection.<locals>.SomeProtocol.connectionMadez  s   ø€ Ø—‘˜dŸn™nÖ-r"   r   N)r   r   r   r    rÁ   r!   rª   ©r¬   rÀ   s   @€r#   r$   r¼   y  s   ù‡ € ÷.ó .r"   r$   N)r   rO   r�   r8   )r(   r$   r‚   r-   rÀ   s   &   @r#   Útest_makeConnectionÚ!ProtocolTests.test_makeConnectionr  sF   ø€ ð
 ˆ÷	.œ8ô 	.ô “Hˆ	Ù“>ˆØ×Ñ 	Ô*Ø×Ñ˜ ) Ö-r"   r   N)
r   r   r   r    r©   r±   r¸   rÄ   r!   rª   r«   s   @r#   r®   r®   [  s   ø‡ € ñò>ò?÷.ð .r"   r®   c                   óH   a € ] tR tRt o RtR tR tR tR tR t	R t
R	tV tR
# )ÚFactoryTestsiƒ  z 
Tests for L{protocol.Factory}.
c                ó–   € \        4       pV P                  \        \        V4      4       V P                  \        \        V4      4       R# )zO
L{Factory} instances provide both L{IProtocolFactory} and
L{ILoggingContext}.
N)r   rG   r   r	   r   )r(   r,   s   & r#   r±   ÚFactoryTests.test_interfacesˆ  s2   € ô
 “)ˆØ�‰œÔ%5°wÓ?Ô@Ø�‰œ¤_°gÓ>Ö?r"   c                ón   €  ! R R\         4      pV P                  RV! 4       P                  4       4       R# )z=
L{Factory.logPrefix} returns the name of the factory class.
c                   ó   € ] tR tRtRtR# )Ú6FactoryTests.test_logPrefix.<locals>.SomeKindOfFactoryi–  r   Nr   r   r"   r#   ÚSomeKindOfFactoryrÌ   –  r%   r"   rÍ   N)r   r8   r·   )r(   rÍ   s   & r#   r¸   ÚFactoryTests.test_logPrefix‘  s.   € ô
	¤ô 	ð 	×ÑÐ,Ñ.?Ó.A×.KÑ.KÓ.MÖNr"   c                óÀ   €  ! R R\         4      p\        4       pWn        VP                  R4      pV P	                  W14       V P                  VP                  V4       R# )z‰
L{Factory.buildProtocol} by default constructs a protocol by calling
its C{protocol} attribute, and attaches the factory to the result.
c                   ó   € ] tR tRtRtR# )Ú<FactoryTests.test_defaultBuildProtocol.<locals>.SomeProtocoli¡  r   Nr   r   r"   r#   r$   rÑ   ¡  r%   r"   r$   N)r   r   r-   r&   r'   rR   r,   )r(   r$   Úfr-   s   &   r#   Útest_defaultBuildProtocolÚ&FactoryTests.test_defaultBuildProtocol›  sL   € ô	œ8ô 	ô ‹IˆØ!Œ
Ø—?‘? 4Ó(ˆØ×Ñ˜hÔ5Ø�‰�h×&Ñ&¨Ö*r"   c                ó
  €  ! R R\         4      pVP                  \        ^^^R7      pV P                  VP                  \        4       V P                  VP
                  R4       V P                  VP                  R^/4       R# )z™
L{Factory.forProtocol} constructs a Factory, passing along any
additional arguments, and sets its C{protocol} attribute to the given
Protocol subclass.
c                   ó&   a € ] tR tRt o R tRtV tR# )Ú7FactoryTests.test_forProtocol.<locals>.ArgTakingFactoryi±  c                ó"   € WuV n         V n        R # r¾   ©ÚargsÚkwargs)r(   rÚ   rÛ   s   &*,r#   Ú__init__Ú@FactoryTests.test_forProtocol.<locals>.ArgTakingFactory.__init__²  s   € Ø)-Ð&�”	˜4ž;r"   rÙ   N)r   r   r   r    rÜ   r!   rª   r«   s   @r#   ÚArgTakingFactoryr×   ±  s   ø‡ € ÷6ð 6r"   rÞ   )Úfoorß   N)é   é   )r   ÚforProtocolr   r8   r-   rÚ   rÛ   )r(   rÞ   r,   s   &  r#   Útest_forProtocolÚFactoryTests.test_forProtocolª  sk   € ô	6œwô 	6ð #×.Ñ.¬x¸¸AÀ2Ð.ÓFˆØ×Ñ˜×)Ñ)¬8Ô4Ø×Ñ˜Ÿ™ vÔ.Ø×Ñ˜Ÿ™¨%°¨Ö5r"   c                ó†  a€ . o\         P                  ! SP                  4       V P                  V3R l4       \	        4       pVP                  4        V P                  S^ ,          R,          V4       V P                  S^ ,          R,          \        P                  4       V P                  S^ ,          R,          R4       R# )z‚
L{Factory.doStart} logs that it is starting a factory, followed by
the L{repr} of the L{Factory} instance that is being started.
c                  óD   <€ \         P                  ! S P                  4      # r¾   ©r   ÚremoveObserverr¿   ©Úeventss   €r#   Ú<lambda>Ú;FactoryTests.test_doStartLoggingStatement.<locals>.<lambda>Á  ó   ø€ Ô 2× AÒ AÀ&Ç-Á-Ô Pr"   r,   Ú	log_levelÚ
log_formatzStarting factory {factory!r}N)
r   ÚaddObserverr¿   Ú
addCleanupr   ÚdoStartrR   r8   r   Úinfo)r(   rÒ   rê   s   & @r#   Útest_doStartLoggingStatementÚ)FactoryTests.test_doStartLoggingStatementº  s‡   ø€ ð
 ˆÜ×&Ò& v§}¡}Ô5Ø�‰ÔPÔQä‹IˆØ	�	‰	Œà�‰�f˜Q•i 	Õ*¨AÔ.Ø×Ñ˜ � ;Õ/´·±Ô?Ø×Ñ˜ � <Õ0Ð2PÖQr"   c                óž  a€ . o\         P                  ! SP                  4       V P                  V3R l4        ! R R\        4      pV! 4       pVP                  4        V P                  S^ ,          R,          V4       V P                  S^ ,          R,          \        P                  4       V P                  S^ ,          R,          R4       R# )	z�
L{Factory.doStop} logs that it is stopping a factory, followed by
the L{repr} of the L{Factory} instance that is being stopped.
c                  óD   <€ \         P                  ! S P                  4      # r¾   rç   ré   s   €r#   rë   Ú:FactoryTests.test_doStopLoggingStatement.<locals>.<lambda>Ñ  rí   r"   c                   ó   € ] tR tRt^tRtR# )Ú;FactoryTests.test_doStopLoggingStatement.<locals>.MyFactoryiÓ  r   N)r   r   r   r    ÚnumPortsr!   r   r"   r#   Ú	MyFactoryrú   Ó  s   † ØŒHr"   rü   r,   rî   rï   zStopping factory {factory!r}N)
r   rð   r¿   rñ   r   ÚdoStoprR   r8   r   ró   )r(   rü   rÒ   rê   s   &  @r#   Útest_doStopLoggingStatementÚ(FactoryTests.test_doStopLoggingStatementÊ  s•   ø€ ð
 ˆÜ×&Ò& v§}¡}Ô5Ø�‰ÔPÔQô	œô 	ñ ‹KˆØ	�‰Œ
à�‰�f˜Q•i 	Õ*¨AÔ.Ø×Ñ˜ � ;Õ/´·±Ô?Ø×Ñ˜ � <Õ0Ð2PÖQr"   r   N)r   r   r   r    r©   r±   r¸   rÓ   rã   rô   rþ   r!   rª   r«   s   @r#   rÇ   rÇ   ƒ  s2   ø‡ € ñò@òOò+ò6ò R÷ Rð Rr"   rÇ   c                   ó0   a € ] tR tRt o RtR tR tRtV tR# )ÚAdapterTestsiÞ  zJ
Tests for L{ProtocolToConsumerAdapter} and L{ConsumerToProtocolAdapter}.
c                óÊ   € . p\        4       pVP                  Vn        \        V4      pVP	                  R4       V P                  VR.4       V P                  V\        4       R# )ze
L{IProtocol} providers can be adapted to L{IConsumer} providers using
L{ProtocolToConsumerAdapter}.
ó   helloN)r   r¿   ÚdataReceivedr   Úwriter8   r'   r   )r(   rÀ   ÚpÚconsumers   &   r#   Útest_protocolToConsumerÚ$AdapterTests.test_protocolToConsumerã  sS   € ð
 ˆÜ‹JˆØŸ™ˆŒÜ˜Q“<ˆØ�‰�xÔ Ø×Ñ˜ ( Ô,Ø×Ñ˜hÔ(AÖBr"   c                óâ   a€ . o\        \        4       ! V3R lR4      4       pV! 4       p\        V4      pVP                  R4       V P	                  SR.4       V P                  V\        4       R# )ze
L{IConsumer} providers can be adapted to L{IProtocol} providers using
L{ProtocolToConsumerAdapter}.
c                   ó.   <a € ] tR tRt o V3R ltRtV tR# )Ú6AdapterTests.test_consumerToProtocol.<locals>.Consumeri÷  c                ó*   <€ SP                  V4       R # r¾   )r¿   )r(   r`   rÀ   s   &&€r#   r  Ú<AdapterTests.test_consumerToProtocol.<locals>.Consumer.writeù  s   ø€ Ø—‘˜aÖ r"   r   N)r   r   r   r    r  r!   rª   rÃ   s   @€r#   ÚConsumerr  ÷  s   ù‡ € ÷!ó !r"   r  r  N)r   r   r   r  r8   r'   r   )r(   r  Úcr-   rÀ   s   &   @r#   Útest_consumerToProtocolÚ$AdapterTests.test_consumerToProtocolð  si   ø€ ð
 ˆä	”YÓ	÷	!ó 	!ó 
 ð	!ñ ‹JˆÜ˜Q“<ˆØ×Ñ˜hÔ'Ø×Ñ˜ ( Ô,Ø×Ñ˜hÔ(AÖBr"   r   N)	r   r   r   r    r©   r  r  r!   rª   r«   s   @r#   r  r  Þ  s   ø‡ € ñòC÷Cð Cr"   r  c                   ó0   a € ] tR tRt o RtR tR tRtV tR# )ÚFileWrapperTestsi  z*
L{twisted.internet.protocol.FileWrapper}
c                ó>  € \        \        4       4      pVP                  R4       V P                  VP                  P                  4       R4       \        \        4       4      pVP                  R4       V P                  VP                  P                  4       R4       R# )z0
L{twisted.internet.protocol.FileWrapper.write}
ó   test1ÚstuffN)r   r   r  r8   ÚfileÚgetvalueÚassertNotEqual©r(   Úwrappers   & r#   Ú
test_writeÚFileWrapperTests.test_write  sp   € ô œg›iÓ(ˆØ�‰�hÔØ×Ñ˜Ÿ™×.Ñ.Ó0°(Ô;äœg›iÓ(ˆð 	�‰�gÔØ×Ñ˜GŸL™L×1Ñ1Ó3°WÖ=r"   c                ó  € \        \        4       4      pVP                  RR.4       V P                  VP                  P                  4       R4       \        \        4       4      pV P                  \        VP                  RR.4       R# )z8
L{twisted.internet.protocol.FileWrapper.writeSequence}
r  s   test2s
   test1test2Útest3Útest4N)r   r   ÚwriteSequencer8   r  r  ÚassertRaisesÚ	TypeErrorr  s   & r#   Útest_writeSequenceÚ#FileWrapperTests.test_writeSequence  si   € ô œg›iÓ(ˆØ×Ñ˜x¨Ð2Ô3Ø×Ñ˜Ÿ™×.Ñ.Ó0°-Ô@äœg›iÓ(ˆà×Ñœ) W×%:Ñ%:¸WÀgÐ<NÖOr"   r   N)	r   r   r   r    r©   r  r%  r!   rª   r«   s   @r#   r  r    s   ø‡ € ñò>÷
Pð 
Pr"   r  N)$r©   Úior   Úzope.interfacer   Úzope.interface.verifyr   Útwisted.internet.deferr   Útwisted.internet.interfacesr   r   r   r	   Útwisted.internet.protocolr
   r   r   r   r   r   Útwisted.internet.testingr   r   Útwisted.loggerr   r   Útwisted.python.failurer   Útwisted.trial.unittestr   r   r®   rÇ   r  r  r   r"   r#   Ú<module>r1     s…   ðñõ
 å &Ý .å 1÷ó ÷÷ ÷ Iß 7Ý *Ý +ôu=˜ô u=ôp	%.�Hô %.ôPXR�8ô XRôv"C�8ô "CôJP�xö Pr"   