ó
    Ö›‘hVH  ã                   ó  • S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
JrJrJr  SSKJrJrJrJrJrJr  SSKJrJr  SS	KJrJr  SS
KJr  SSKJr   " S S\5      r " S S\5      r  " S S\5      r! " S S\5      r" " S S\5      r#g)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                   óx   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rSrg)ÚClientCreatorTestsé#   z7
Tests for L{twisted.internet.protocol.ClientCreator}.
c                 ó    •  " S S[         5      n[        5       n[        X25      nU" X45      nUR                  S5      nU R	                  Xb5        g)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                   ó   • \ rS rSrSrg)Ú:ClientCreatorTests._basicConnectTest.<locals>.SomeProtocolé5   © N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    ÚgC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-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                 ó4   ^ • U 4S jnT R                  U5        g)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                 óü   >• UR                  SSSS5        U R                  R                  5       u  p#pEnTR                  US5        TR                  US5        TR                  US5        TR                  US5        U$ )Nú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©r1   ©r+   r,   s   ` r&   Útest_connectTCPÚ"ClientCreatorTests.test_connectTCP>   s   ø€ õ	ð 	×Ñ˜uÕ%r%   c                 ó4   ^ • U 4S jnT R                  U5        g)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                 óÒ   >• UR                  SSS5        U R                  R                  5       u  p#pETR                  US5        TR                  US5        TR	                  U5        U$ )Nú/foo/baré{   T)ÚconnectUNIXÚunixClientsr:   r;   Ú
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%   NrA   rB   s   ` r&   Útest_connectUNIXÚ#ClientCreatorTests.test_connectUNIXP   s   ø€ õ	ð 	×Ñ˜uÕ%r%   c                 ó4   ^ • U 4S jnT R                  U5        g)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                 ó:  >• [        5       nUR                  SSUSS5        U R                  R                  5       u  nnnnnnT	R	                  US5        T	R	                  US5        T	R                  Xb5        T	R	                  US5        T	R	                  US5        U$ )Nr5   r6   r7   )z4.3.2.1i.  )ÚobjectÚ
connectSSLÚ
sslClientsr:   r;   ÚassertIs)
r-   r.   ÚexpectedContextFactoryr<   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%   NrA   rB   s   ` r&   Útest_connectSSLÚ"ClientCreatorTests.test_connectSSLa   s   ø€ õ	ð( 	×Ñ˜uÕ%r%   c                 ó2  • [        5       n[        U[        5      nU" U5      nUR                  R	                  5       nU R                  UR                  5        UR                  5         U R                  UR                  5        U R                  U[        5      $ )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   Ú
connectorsr:   ÚassertFalseÚ_disconnectedÚcancelrK   ÚassertFailurer   ©r+   Úconnectr-   r.   ÚdÚ	connectors         r&   Ú_cancelConnectTestÚ%ClientCreatorTests._cancelConnectTest~   sw   € ô %Ó&ˆÜ˜7¤HÓ-ˆÙ�B‹KˆØ×&Ñ&×*Ñ*Ó,ˆ	Ø×Ñ˜×0Ñ0Ô1Ø	�‰Œ
Ø�‰˜	×/Ñ/Ô0Ø×!Ñ! !¤^Ó4Ð4r%   c                 ó*   • S nU R                  U5      $ )ú
The L{Deferred} returned by L{ClientCreator.connectTCP} can be cancelled
to abort the connection attempt before it completes.
c                 ó&   • U R                  SS5      $ ©Nr5   r6   )r8   ©r.   s    r&   rc   Ú9ClientCreatorTests.test_cancelConnectTCP.<locals>.connectš   s   € Ø—=‘= °Ó5Ð5r%   ©rf   ©r+   rc   s     r&   Útest_cancelConnectTCPÚ(ClientCreatorTests.test_cancelConnectTCP”   s   € ò	6ð ×&Ñ& wÓ/Ð/r%   c                 ó*   • S nU R                  U5      $ )ri   c                 ó$   • U R                  S5      $ ©NrG   )rI   rl   s    r&   rc   Ú:ClientCreatorTests.test_cancelConnectUNIX.<locals>.connect¥   s   € Ø—>‘> *Ó-Ð-r%   rn   ro   s     r&   Útest_cancelConnectUNIXÚ)ClientCreatorTests.test_cancelConnectUNIXŸ   s   € ò	.ð ×&Ñ& wÓ/Ð/r%   c                 ó*   • S nU R                  U5      $ )ri   c                 ó8   • U R                  SS[        5       5      $ rk   )rT   rS   rl   s    r&   rc   Ú9ClientCreatorTests.test_cancelConnectSSL.<locals>.connect°   s   € Ø—=‘= °´f³hÓ?Ð?r%   rn   ro   s     r&   Útest_cancelConnectSSLÚ(ClientCreatorTests.test_cancelConnectSSLª   s   € ò	@ð ×&Ñ& wÓ/Ð/r%   c                 óŽ  • [        5       n[        U[        5      nU" X#5      nUR                  R	                  5       nU R                  [        UR                  5       5      S5        UR                  5         U R                  UR                  5       / 5        U R                  UR                  5        U R                  U[        5      $ )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   r]   r:   r;   ÚlenÚgetDelayedCallsr`   rK   r_   ra   r   rb   s         r&   Ú_cancelConnectTimeoutTestÚ,ClientCreatorTests._cancelConnectTimeoutTestµ   s¡   € ô %Ó&ˆÜ˜7¤HÓ-ˆÙ�GÓ ˆØ×&Ñ&×*Ñ*Ó,ˆ	ð 	×Ñœ˜W×4Ñ4Ó6Ó7¸Ô;ð 	
�‰Œ
à×Ñ˜×0Ñ0Ó2°BÔ7ð
 	�‰˜	×/Ñ/Ô0à×!Ñ! !¤^Ó4Ð4r%   c                 ó*   • S nU R                  U5      $ )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                 ó¾   • UR                  SS5      nU R                  R                  5       u  p4pVnUR                  S 5      n[	        5       n	UR                  U	5        U$ rk   )r8   r9   r:   r)   r   ÚmakeConnection)
r-   r.   rd   r<   r=   r/   r>   r?   r0   Ú	transports
             r&   rc   Ú@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�   ro   s     r&   Útest_cancelConnectTCPTimeoutÚ/ClientCreatorTests.test_cancelConnectTCPTimeoutÐ   ó   € ò	ð ×-Ñ-¨gÓ6Ð6r%   c                 ó*   • S nU R                  U5      $ )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                 óº   • UR                  S5      nU R                  R                  5       u  p4pVUR                  S 5      n[	        5       nUR                  U5        U$ rt   )rI   rJ   r:   r)   r   r…   )	r-   r.   rd   rL   r/   r>   r?   r0   r†   s	            r&   rc   ÚAClientCreatorTests.test_cancelConnectUNIXTimeout.<locals>.connectî   sT   € Ø—‘˜zÓ*ˆAØ5<×5HÑ5H×5LÑ5LÓ5NÑ2ˆG˜gØ×,Ñ,¨TÓ2ˆHÜ'Ó)ˆIØ×#Ñ# IÔ.ØˆHr%   rˆ   ro   s     r&   Útest_cancelConnectUNIXTimeoutÚ0ClientCreatorTests.test_cancelConnectUNIXTimeoutä   r‹   r%   c                 ó*   • S nU R                  U5      $ )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                 óÖ   • UR                  SS[        5       5      nU R                  R                  5       u  nnnnnnUR	                  S 5      n	[        5       n
U	R                  U
5        U$ rk   )rT   rS   rU   r:   r)   r   r…   )r-   r.   rd   r<   r=   r/   rX   r>   ÚbindADdressr0   r†   s              r&   rc   Ú@ClientCreatorTests.test_cancelConnectSSLTimeout.<locals>.connect  sl   € Ø—‘˜m¨T´6³8Ó<ˆAð ×"Ñ"×&Ñ&Ó(ñØØØØØØà×,Ñ,¨TÓ2ˆHÜ'Ó)ˆIØ×#Ñ# IÔ.ØˆHr%   rˆ   ro   s     r&   Útest_cancelConnectSSLTimeoutÚ/ClientCreatorTests.test_cancelConnectSSLTimeoutø   s   € ò	ð ×-Ñ-¨gÓ6Ð6r%   c                 ó¤  • [        5       n[        U[        5      nU" X#5      u  pEUR                  R	                  5       nUR                  U[        [        S5      5      5        U R                  [        UR                  5       5      S5        UR                  5         U R                  UR                  5       / 5        U R                  U[        5      $ )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 failurer~   )r   r   r   r]   r:   ÚclientConnectionFailedr   Ú	Exceptionr;   r   r€   r`   ra   r   )r+   rc   r-   r.   rd   r/   re   s          r&   Ú_cancelConnectFailedTimeoutTestÚ2ClientCreatorTests._cancelConnectFailedTimeoutTest  s­   € ô %Ó&ˆÜ˜7¤HÓ-ˆÙ˜WÓ)‰
ˆØ×&Ñ&×*Ñ*Ó,ˆ	Ø×&Ñ&Ø”wœyÐ)<Ó=Ó>ô	
ð 	×Ñœ˜W×4Ñ4Ó6Ó7¸Ô;ð 	
�‰Œ
à×Ñ˜×0Ñ0Ó2°BÔ7à×!Ñ! !¤^Ó4Ð4r%   c                 ó*   • S nU R                  U5      $ )zb
Similar to L{test_cancelConnectTCPTimeout}, but for the case where the
connection attempt fails.
c                 óh   • UR                  SS5      nU R                  R                  5       u  p4pVnX%4$ rk   )r8   r9   r:   )r-   r.   rd   r<   r=   r/   r>   r?   s           r&   rc   ÚFClientCreatorTests.test_cancelConnectTCPFailedTimeout.<locals>.connect2  s5   € Ø—‘˜m¨TÓ2ˆAØ8?×8JÑ8J×8NÑ8NÓ8PÑ5ˆD˜¨+Ø�:Ðr%   ©rš   ro   s     r&   Ú"test_cancelConnectTCPFailedTimeoutÚ5ClientCreatorTests.test_cancelConnectTCPFailedTimeout,  ó   € ò	ð
 ×3Ñ3°GÓ<Ð<r%   c                 ó*   • S nU R                  U5      $ )zc
Similar to L{test_cancelConnectUNIXTimeout}, but for the case where the
connection attempt fails.
c                 ód   • UR                  S5      nU R                  R                  5       u  p4pVX$4$ rt   )rI   rJ   r:   )r-   r.   rd   rL   r/   r>   r?   s          r&   rc   ÚGClientCreatorTests.test_cancelConnectUNIXFailedTimeout.<locals>.connect?  s1   € Ø—‘˜zÓ*ˆAØ5<×5HÑ5H×5LÑ5LÓ5NÑ2ˆG˜gØ�:Ðr%   rŸ   ro   s     r&   Ú#test_cancelConnectUNIXFailedTimeoutÚ6ClientCreatorTests.test_cancelConnectUNIXFailedTimeout9  r¢   r%   c                 ó*   • S nU R                  U5      $ )zb
Similar to L{test_cancelConnectSSLTimeout}, but for the case where the
connection attempt fails.
c                 ó€   • UR                  SS[        5       5      nU R                  R                  5       u  nnnnnnX%4$ rk   )rT   rS   rU   r:   )	r-   r.   rd   r<   r=   r/   rX   r>   r“   s	            r&   rc   ÚFClientCreatorTests.test_cancelConnectSSLFailedTimeout.<locals>.connectL  sI   € Ø—‘˜m¨T´6³8Ó<ˆAð ×"Ñ"×&Ñ&Ó(ñØØØØØØà�:Ðr%   rŸ   ro   s     r&   Ú"test_cancelConnectSSLFailedTimeoutÚ5ClientCreatorTests.test_cancelConnectSSLFailedTimeoutF  s   € ò
	ð ×3Ñ3°GÓ<Ð<r%   r   N)r    r!   r"   r#   Ú__doc__r1   rC   rO   rZ   rf   rp   rv   r{   r�   r‰   r�   r•   rš   r    r¦   r«   r$   r   r%   r&   r   r   #   sW   † ñò6ò,&ò$&ò"&ò:5ò,	0ò	0ò	0ò5ò67ò(7ò(7ò65ò2=ò=õ=r%   r   c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚProtocolTestsi[  z2
Tests for L{twisted.internet.protocol.Protocol}.
c                 ó”   • [        5       nU R                  [        [        U5      5        U R                  [        [        U5      5        g)zD
L{Protocol} instances provide L{IProtocol} and L{ILoggingContext}.
N)r   rK   r   r	   r   )r+   Úprotos     r&   Útest_interfacesÚProtocolTests.test_interfaces`  s1   € ô “
ˆØ�‰œ¤Y°Ó6Ô7Ø�‰œ¤_°eÓ<Õ=r%   c                 ól   •  " S S[         5      nU R                  SU" 5       R                  5       5        g)z:
L{Protocol.logPrefix} returns the protocol class's name.
c                   ó   • \ rS rSrSrg)Ú/ProtocolTests.test_logPrefix.<locals>.SomeThingim  r   Nr   r   r%   r&   Ú	SomeThingr¶   m  r(   r%   r·   N)r   r;   Ú	logPrefix)r+   r·   s     r&   Útest_logPrefixÚProtocolTests.test_logPrefixh  s+   € ô
	œô 	ð 	×Ñ˜¡i£k×&;Ñ&;Ó&=Õ>r%   c                 ó˜   ^• / m " U4S jS[         5      n[        5       nU" 5       nUR                  U5        U R                  TU/5        g)zb
L{Protocol.makeConnection} sets the given transport on itself, and
then calls C{connectionMade}.
c                   ó"   >• \ rS rSrU 4S jrSrg)Ú7ProtocolTests.test_makeConnection.<locals>.SomeProtocoliy  c                 ó<   >• TR                  U R                  5        g ©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Á   s   €r&   r'   r½   y  s   ø† ÷.ð .r%   r'   N)r   rS   r…   r;   )r+   r'   r†   r0   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%   r&   r¯   r¯   [  s   † ñò>ò?õ.r%   r¯   c                   ó<   • \ rS rSrSrS rS rS rS rS r	S r
S	rg
)ÚFactoryTestsiƒ  z 
Tests for L{protocol.Factory}.
c                 ó”   • [        5       nU R                  [        [        U5      5        U R                  [        [        U5      5        g)zO
L{Factory} instances provide both L{IProtocolFactory} and
L{ILoggingContext}.
N)r   rK   r   r
   r   )r+   r/   s     r&   r²   ÚFactoryTests.test_interfacesˆ  s2   € ô
 “)ˆØ�‰œÔ%5°wÓ?Ô@Ø�‰œ¤_°gÓ>Õ?r%   c                 ól   •  " S S[         5      nU R                  SU" 5       R                  5       5        g)z=
L{Factory.logPrefix} returns the name of the factory class.
c                   ó   • \ rS rSrSrg)Ú6FactoryTests.test_logPrefix.<locals>.SomeKindOfFactoryi–  r   Nr   r   r%   r&   ÚSomeKindOfFactoryrÍ   –  r(   r%   rÎ   N)r   r;   r¸   )r+   rÎ   s     r&   r¹   ÚFactoryTests.test_logPrefix‘  s.   € ô
	¤ô 	ð 	×ÑÐ,Ñ.?Ó.A×.KÑ.KÓ.MÕNr%   c                 ó¾   •  " S S[         5      n[        5       nXl        UR                  S5      nU R	                  X15        U R                  UR                  U5        g)z‰
L{Factory.buildProtocol} by default constructs a protocol by calling
its C{protocol} attribute, and attaches the factory to the result.
c                   ó   • \ rS rSrSrg)Ú<FactoryTests.test_defaultBuildProtocol.<locals>.SomeProtocoli¡  r   Nr   r   r%   r&   r'   rÒ   ¡  r(   r%   r'   N)r   r   r0   r)   r*   rV   r/   )r+   r'   Úfr0   s       r&   Útest_defaultBuildProtocolÚ&FactoryTests.test_defaultBuildProtocol›  sL   € ô	œ8ô 	ô ‹IˆØ!Œ
Ø—?‘? 4Ó(ˆØ×Ñ˜hÔ5Ø�‰�h×&Ñ&¨Õ*r%   c                 ó  •  " S S[         5      nUR                  [        SSSS9nU R                  UR                  [        5        U R                  UR
                  S5        U R                  UR                  SS05        g	)
z™
L{Factory.forProtocol} constructs a Factory, passing along any
additional arguments, and sets its C{protocol} attribute to the given
Protocol subclass.
c                   ó   • \ rS rSrS rSrg)Ú7FactoryTests.test_forProtocol.<locals>.ArgTakingFactoryi±  c                 ó    • XsU l         U l        g 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%   r&   ÚArgTakingFactoryrØ   ±  s   † õ6r%   rß   r~   é   é   )Úfoo)r~   rà   râ   N)r   ÚforProtocolr   r;   r0   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                 óT  ^• / m[         R                  " TR                  5        U R                  U4S j5        [	        5       nUR                  5         U R                  TS   S   U5        U R                  TS   S   [        R                  5        U R                  TS   S   S5        g)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   >• [         R                  " T R                  5      $ r¿   ©r   ÚremoveObserverrÀ   ©Úeventss   €r&   Ú<lambda>Ú;FactoryTests.test_doStartLoggingStatement.<locals>.<lambda>Á  ó   ø€ Ô 2× AÒ AÀ&Ç-Á-Ô Pr%   r   r/   Ú	log_levelÚ
log_formatzStarting factory {factory!r}N)
r   ÚaddObserverrÀ   Ú
addCleanupr   ÚdoStartrV   r;   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                 ól  ^• / m[         R                  " TR                  5        U R                  U4S j5         " S S[        5      nU" 5       nUR                  5         U R                  TS   S   U5        U R                  TS   S   [        R                  5        U R                  TS   S   S5        g	)
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   >• [         R                  " T R                  5      $ r¿   rè   rê   s   €r&   rì   Ú:FactoryTests.test_doStopLoggingStatement.<locals>.<lambda>Ñ  rî   r%   c                   ó   • \ rS rSrSrSrg)Ú;FactoryTests.test_doStopLoggingStatement.<locals>.MyFactoryiÓ  r~   r   N)r    r!   r"   r#   ÚnumPortsr$   r   r%   r&   Ú	MyFactoryrû   Ó  s   † Ø‹Hr%   rý   r   r/   rï   rð   zStopping factory {factory!r}N)
r   rñ   rÀ   rò   r   ÚdoStoprV   r;   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%   r&   rÈ   rÈ   ƒ  s)   † ñò@òOò+ò6ò Rõ Rr%   rÈ   c                   ó$   • \ rS rSrSrS rS rSrg)ÚAdapterTestsiÞ  zJ
Tests for L{ProtocolToConsumerAdapter} and L{ConsumerToProtocolAdapter}.
c                 óÈ   • / n[        5       nUR                  Ul        [        U5      nUR	                  S5        U R                  US/5        U R                  U[        5        g)ze
L{IProtocol} providers can be adapted to L{IConsumer} providers using
L{ProtocolToConsumerAdapter}.
ó   helloN)r   rÀ   ÚdataReceivedr   Úwriter;   r*   r   )r+   rÁ   ÚpÚconsumers       r&   Útest_protocolToConsumerÚ$AdapterTests.test_protocolToConsumerã  sS   € ð
 ˆÜ‹JˆØŸ™ˆŒÜ˜Q“<ˆØ�‰�xÔ Ø×Ñ˜ ( Ô,Ø×Ñ˜hÔ(AÕBr%   c                 óà   ^• / m[        [        5       " U4S jS5      5       nU" 5       n[        U5      nUR                  S5        U R	                  TS/5        U R                  U[        5        g)ze
L{IConsumer} providers can be adapted to L{IProtocol} providers using
L{ProtocolToConsumerAdapter}.
c                   ó"   >• \ rS rSrU 4S jrSrg)Ú6AdapterTests.test_consumerToProtocol.<locals>.Consumeri÷  c                 ó(   >• TR                  U5        g r¿   )rÀ   )r+   rd   rÁ   s     €r&   r  Ú<AdapterTests.test_consumerToProtocol.<locals>.Consumer.writeù  s   ø€ Ø—‘˜aÕ r%   r   N)r    r!   r"   r#   r  r$   rÄ   s   €r&   ÚConsumerr  ÷  s   ø† ÷!ð !r%   r  r  N)r   r   r	   r  r;   r*   r   )r+   r  Úcr0   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%   r&   r  r  Þ  s   † ñòCõCr%   r  c                   ó$   • \ rS rSrSrS rS rSrg)ÚFileWrapperTestsi  z*
L{twisted.internet.protocol.FileWrapper}
c                 ó<  • [        [        5       5      nUR                  S5        U R                  UR                  R                  5       S5        [        [        5       5      nUR                  S5        U R                  UR                  R                  5       S5        g)z0
L{twisted.internet.protocol.FileWrapper.write}
ó   test1ÚstuffN)r   r   r  r;   Ú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                 ó  • [        [        5       5      nUR                  SS/5        U R                  UR                  R                  5       S5        [        [        5       5      nU R                  [        UR                  SS/5        g)z8
L{twisted.internet.protocol.FileWrapper.writeSequence}
r  s   test2s
   test1test2Útest3Útest4N)r   r   ÚwriteSequencer;   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%   r&   r  r    s   † ñò>õ
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>r2     s…   ðñõ
 å &Ý .å 1÷ó ÷÷ ÷ Iß 7Ý *Ý +ôu=˜ô u=ôp	%.�Hô %.ôPXR�8ô XRôv"C�8ô "CôJP�xõ Pr%   