§
    ÈtºfVH  ã                   ó6  — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZmZ ddlmZmZmZmZmZmZ ddlmZmZ dd	lmZmZ dd
lmZ ddlmZ  G d„ de¦  «        Z G d„ de¦  «        Z  G d„ de¦  «        Z! G d„ de¦  «        Z" G d„ de¦  «        Z#dS )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                   ór   — 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dS )ÚClientCreatorTestsz?
    Tests for L{twisted.internet.protocol.ClientCreator}.
    c                 óÖ   —  G d„ dt           ¦  «        }t          ¦   «         }t          ||¦  «        } |||¦  «        }|                     d¦  «        }|                      ||¦  «         dS )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                   ó   — e Zd ZdS )ú:ClientCreatorTests._basicConnectTest.<locals>.SomeProtocolN©Ú__name__Ú
__module__Ú__qualname__© ó    úb/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/internet/test/test_protocol.pyÚSomeProtocolr   5   ó   € € € € € ØˆDr!   r#   N)r   r   r   ÚbuildProtocolÚassertIsInstance)ÚselfÚcheckr#   ÚreactorÚccÚfactoryÚprotocols          r"   Ú_basicConnectTestz$ClientCreatorTests._basicConnectTest(   sˆ   € ð	ð 	ð 	ð 	ð 	�8ñ 	ô 	ð 	õ %Ñ&Ô&ˆÝ˜7 LÑ1Ô1ˆØ�%˜ Ñ$Ô$ˆØ×(Ò(¨Ñ.Ô.ˆØ×Ò˜h¨Ñ5Ô5Ð5Ð5Ð5r!   c                 ó<   ‡ — ˆ fd„}‰                       |¦  «         dS )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                 ó&  •— |                      dddd¦  «         | j                             ¦   «         \  }}}}}‰                     |d¦  «         ‰                     |d¦  «         ‰                     |d¦  «         ‰                     |d¦  «         |S )Núexample.coméÒ  éá  )z1.2.3.4i”&  )Ú
connectTCPÚ
tcpClientsÚpopÚassertEqual)r)   r*   ÚhostÚportr+   ÚtimeoutÚbindAddressr'   s          €r"   r(   z1ClientCreatorTests.test_connectTCP.<locals>.checkE   s™   ø€ Ø�MŠM˜-¨¨tÐ5FÑGÔGÐGØ8?Ô8J×8NÒ8NÑ8PÔ8PÑ5ˆD�$˜ ¨+Ø×Ò˜T =Ñ1Ô1Ð1Ø×Ò˜T 4Ñ(Ô(Ð(Ø×Ò˜W dÑ+Ô+Ð+Ø×Ò˜[Ð*;Ñ<Ô<Ð<ØˆNr!   N©r-   ©r'   r(   s   ` r"   Útest_connectTCPz"ClientCreatorTests.test_connectTCP>   s8   ø€ ð	ð 	ð 	ð 	ð 	ð 	×Ò˜uÑ%Ô%Ð%Ð%Ð%r!   c                 ó<   ‡ — ˆ fd„}‰                       |¦  «         dS )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                 óô   •— |                      ddd¦  «         | j                             ¦   «         \  }}}}‰                     |d¦  «         ‰                     |d¦  «         ‰                     |¦  «         |S )Nú/foo/baré{   T)ÚconnectUNIXÚunixClientsr5   r6   Ú
assertTrue)r)   r*   Úaddressr+   r9   ÚcheckPIDr'   s         €r"   r(   z2ClientCreatorTests.test_connectUNIX.<locals>.checkW   sy   ø€ Ø�NŠN˜: s¨DÑ1Ô1Ð1Ø29Ô2E×2IÒ2IÑ2KÔ2KÑ/ˆG�W˜g xØ×Ò˜W jÑ1Ô1Ð1Ø×Ò˜W cÑ*Ô*Ð*Ø�OŠO˜HÑ%Ô%Ð%ØˆNr!   Nr;   r<   s   ` r"   Útest_connectUNIXz#ClientCreatorTests.test_connectUNIXP   s8   ø€ ð	ð 	ð 	ð 	ð 	ð 	×Ò˜uÑ%Ô%Ð%Ð%Ð%r!   c                 ó<   ‡ — ˆ fd„}‰                       |¦  «         dS )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                 ór  •— t          ¦   «         }|                     dd|dd¦  «         | j                             ¦   «         \  }}}}}}‰	                     |d¦  «         ‰	                     |d¦  «         ‰	                     ||¦  «         ‰	                     |d¦  «         ‰	                     |d¦  «         |S )Nr0   r1   r2   )z4.3.2.1i.  )ÚobjectÚ
connectSSLÚ
sslClientsr5   r6   ÚassertIs)
r)   r*   ÚexpectedContextFactoryr7   r8   r+   ÚcontextFactoryr9   r:   r'   s
            €r"   r(   z1ClientCreatorTests.test_connectSSL.<locals>.checkh   sÎ   ø€ Ý%+¡X¤XÐ"Ø�MŠMØ˜tÐ%;¸TÐCTñô ð ð Ô"×&Ò&Ñ(Ô(ñØØØØØØà×Ò˜T =Ñ1Ô1Ð1Ø×Ò˜T 4Ñ(Ô(Ð(Ø�MŠM˜.Ð*@ÑAÔAÐAØ×Ò˜W dÑ+Ô+Ð+Ø×Ò˜[Ð*;Ñ<Ô<Ð<ØˆNr!   Nr;   r<   s   ` r"   Útest_connectSSLz"ClientCreatorTests.test_connectSSLa   s8   ø€ ð	ð 	ð 	ð 	ð 	ð( 	×Ò˜uÑ%Ô%Ð%Ð%Ð%r!   c                 óV  — t          ¦   «         }t          |t          ¦  «        } ||¦  «        }|j                             ¦   «         }|                      |j        ¦  «         |                     ¦   «          |                      |j        ¦  «         |  	                    |t          ¦  «        S )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   Ú
connectorsr5   ÚassertFalseÚ_disconnectedÚcancelrD   ÚassertFailurer   ©r'   Úconnectr)   r*   ÚdÚ	connectors         r"   Ú_cancelConnectTestz%ClientCreatorTests._cancelConnectTest~   sŽ   € õ %Ñ&Ô&ˆÝ˜7¥HÑ-Ô-ˆØˆG�B‰KŒKˆØÔ&×*Ò*Ñ,Ô,ˆ	Ø×Ò˜Ô0Ñ1Ô1Ð1Ø	�Š‰
Œ
ˆ
Ø�Š˜	Ô/Ñ0Ô0Ð0Ø×!Ò! !¥^Ñ4Ô4Ð4r!   c                 ó2   — d„ }|                       |¦  «        S )ú—
        The L{Deferred} returned by L{ClientCreator.connectTCP} can be cancelled
        to abort the connection attempt before it completes.
        c                 ó.   — |                       dd¦  «        S ©Nr0   r1   )r3   ©r*   s    r"   rX   z9ClientCreatorTests.test_cancelConnectTCP.<locals>.connectš   s   € Ø—=’= °Ñ5Ô5Ð5r!   ©r[   ©r'   rX   s     r"   Útest_cancelConnectTCPz(ClientCreatorTests.test_cancelConnectTCP”   s'   € ð	6ð 	6ð 	6ð ×&Ò& wÑ/Ô/Ð/r!   c                 ó2   — d„ }|                       |¦  «        S )r]   c                 ó,   — |                       d¦  «        S ©Nr@   )rB   r`   s    r"   rX   z:ClientCreatorTests.test_cancelConnectUNIX.<locals>.connect¥   s   € Ø—>’> *Ñ-Ô-Ð-r!   ra   rb   s     r"   Útest_cancelConnectUNIXz)ClientCreatorTests.test_cancelConnectUNIXŸ   s'   € ð	.ð 	.ð 	.ð ×&Ò& wÑ/Ô/Ð/r!   c                 ó2   — d„ }|                       |¦  «        S )r]   c                 óH   — |                       ddt          ¦   «         ¦  «        S r_   )rK   rJ   r`   s    r"   rX   z9ClientCreatorTests.test_cancelConnectSSL.<locals>.connect°   s   € Ø—=’= °µf±h´hÑ?Ô?Ð?r!   ra   rb   s     r"   Útest_cancelConnectSSLz(ClientCreatorTests.test_cancelConnectSSLª   s*   € ð	@ð 	@ð 	@ð ×&Ò& wÑ/Ô/Ð/r!   c                 óÞ  — t          ¦   «         }t          |t          ¦  «        } |||¦  «        }|j                             ¦   «         }|                      t          |                     ¦   «         ¦  «        d¦  «         |                     ¦   «          |                      |                     ¦   «         g ¦  «         |  	                    |j
        ¦  «         |                      |t          ¦  «        S )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   rR   r5   r6   ÚlenÚgetDelayedCallsrU   rD   rT   rV   r   rW   s         r"   Ú_cancelConnectTimeoutTestz,ClientCreatorTests._cancelConnectTimeoutTestµ   sÍ   € õ %Ñ&Ô&ˆÝ˜7¥HÑ-Ô-ˆØˆG�G˜RÑ Ô ˆØÔ&×*Ò*Ñ,Ô,ˆ	ð 	×Ò�˜W×4Ò4Ñ6Ô6Ñ7Ô7¸Ñ;Ô;Ð;ð 	
�Š‰
Œ
ˆ
à×Ò˜×0Ò0Ñ2Ô2°BÑ7Ô7Ð7ð
 	�Š˜	Ô/Ñ0Ô0Ð0à×!Ò! !¥^Ñ4Ô4Ð4r!   c                 ó2   — d„ }|                       |¦  «        S )a¡  
        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                 óà   — |                      dd¦  «        }| j                             ¦   «         \  }}}}}|                     d ¦  «        }t	          ¦   «         }	|                     |	¦  «         |S r_   )r3   r4   r5   r%   r   ÚmakeConnection)
r)   r*   rY   r7   r8   r+   r9   r:   r,   Ú	transports
             r"   rX   z@ClientCreatorTests.test_cancelConnectTCPTimeout.<locals>.connectÚ   sk   € Ø—’˜m¨TÑ2Ô2ˆAØ8?Ô8J×8NÒ8NÑ8PÔ8PÑ5ˆD�$˜ ¨+Ø×,Ò,¨TÑ2Ô2ˆHÝ'Ñ)Ô)ˆIØ×#Ò# IÑ.Ô.Ð.ØˆHr!   ©ro   rb   s     r"   Útest_cancelConnectTCPTimeoutz/ClientCreatorTests.test_cancelConnectTCPTimeoutÐ   ó'   € ð	ð 	ð 	ð ×-Ò-¨gÑ6Ô6Ð6r!   c                 ó2   — d„ }|                       |¦  «        S )a¢  
        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                 óÜ   — |                      d¦  «        }| j                             ¦   «         \  }}}}|                     d ¦  «        }t	          ¦   «         }|                     |¦  «         |S rf   )rB   rC   r5   r%   r   rr   )	r)   r*   rY   rE   r+   r9   r:   r,   rs   s	            r"   rX   zAClientCreatorTests.test_cancelConnectUNIXTimeout.<locals>.connectî   sg   € Ø—’˜zÑ*Ô*ˆAØ5<Ô5H×5LÒ5LÑ5NÔ5NÑ2ˆG�W˜g {Ø×,Ò,¨TÑ2Ô2ˆHÝ'Ñ)Ô)ˆIØ×#Ò# IÑ.Ô.Ð.ØˆHr!   rt   rb   s     r"   Útest_cancelConnectUNIXTimeoutz0ClientCreatorTests.test_cancelConnectUNIXTimeoutä   rv   r!   c                 ó2   — d„ }|                       |¦  «        S )a¡  
        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                 óü   — |                      ddt          ¦   «         ¦  «        }| j                             ¦   «         \  }}}}}}|                     d ¦  «        }	t          ¦   «         }
|	                     |
¦  «         |S r_   )rK   rJ   rL   r5   r%   r   rr   )r)   r*   rY   r7   r8   r+   rO   r9   ÚbindADdressr,   rs   s              r"   rX   z@ClientCreatorTests.test_cancelConnectSSLTimeout.<locals>.connect  s}   € Ø—’˜m¨Tµ6±8´8Ñ<Ô<ˆAð Ô"×&Ò&Ñ(Ô(ñØØØØØØà×,Ò,¨TÑ2Ô2ˆHÝ'Ñ)Ô)ˆIØ×#Ò# IÑ.Ô.Ð.ØˆHr!   rt   rb   s     r"   Útest_cancelConnectSSLTimeoutz/ClientCreatorTests.test_cancelConnectSSLTimeoutø   s'   € ð	ð 	ð 	ð ×-Ò-¨gÑ6Ô6Ð6r!   c                 ó  — t          ¦   «         }t          |t          ¦  «        } |||¦  «        \  }}|j                             ¦   «         }|                     |t          t          d¦  «        ¦  «        ¦  «         |                      t          | 
                    ¦   «         ¦  «        d¦  «         |                     ¦   «          |                      | 
                    ¦   «         g ¦  «         |                      |t          ¦  «        S )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 failurerl   )r   r   r   rR   r5   ÚclientConnectionFailedr   Ú	Exceptionr6   rm   rn   rU   rV   r   )r'   rX   r)   r*   rY   r+   rZ   s          r"   Ú_cancelConnectFailedTimeoutTestz2ClientCreatorTests._cancelConnectFailedTimeoutTest  sè   € õ %Ñ&Ô&ˆÝ˜7¥HÑ-Ô-ˆØ�W˜W bÑ)Ô)‰
ˆˆ7ØÔ&×*Ò*Ñ,Ô,ˆ	Ø×&Ò&Ø•w�yÐ)<Ñ=Ô=Ñ>Ô>ñ	
ô 	
ð 	
ð 	×Ò�˜W×4Ò4Ñ6Ô6Ñ7Ô7¸Ñ;Ô;Ð;ð 	
�Š‰
Œ
ˆ
à×Ò˜×0Ò0Ñ2Ô2°BÑ7Ô7Ð7à×!Ò! !¥^Ñ4Ô4Ð4r!   c                 ó2   — d„ }|                       |¦  «        S )zz
        Similar to L{test_cancelConnectTCPTimeout}, but for the case where the
        connection attempt fails.
        c                 ót   — |                      dd¦  «        }| j                             ¦   «         \  }}}}}||fS r_   )r3   r4   r5   )r)   r*   rY   r7   r8   r+   r9   r:   s           r"   rX   zFClientCreatorTests.test_cancelConnectTCPFailedTimeout.<locals>.connect2  s>   € Ø—’˜m¨TÑ2Ô2ˆAØ8?Ô8J×8NÒ8NÑ8PÔ8PÑ5ˆD�$˜ ¨+Ø�g�:Ðr!   ©r�   rb   s     r"   Ú"test_cancelConnectTCPFailedTimeoutz5ClientCreatorTests.test_cancelConnectTCPFailedTimeout,  ó'   € ð	ð 	ð 	ð
 ×3Ò3°GÑ<Ô<Ð<r!   c                 ó2   — d„ }|                       |¦  «        S )z{
        Similar to L{test_cancelConnectUNIXTimeout}, but for the case where the
        connection attempt fails.
        c                 óp   — |                      d¦  «        }| j                             ¦   «         \  }}}}||fS rf   )rB   rC   r5   )r)   r*   rY   rE   r+   r9   r:   s          r"   rX   zGClientCreatorTests.test_cancelConnectUNIXFailedTimeout.<locals>.connect?  s:   € Ø—’˜zÑ*Ô*ˆAØ5<Ô5H×5LÒ5LÑ5NÔ5NÑ2ˆG�W˜g {Ø�g�:Ðr!   r„   rb   s     r"   Ú#test_cancelConnectUNIXFailedTimeoutz6ClientCreatorTests.test_cancelConnectUNIXFailedTimeout9  r†   r!   c                 ó2   — d„ }|                       |¦  «        S )zz
        Similar to L{test_cancelConnectSSLTimeout}, but for the case where the
        connection attempt fails.
        c                 ó�   — |                      ddt          ¦   «         ¦  «        }| j                             ¦   «         \  }}}}}}||fS r_   )rK   rJ   rL   r5   )	r)   r*   rY   r7   r8   r+   rO   r9   r|   s	            r"   rX   zFClientCreatorTests.test_cancelConnectSSLFailedTimeout.<locals>.connectL  sP   € Ø—’˜m¨Tµ6±8´8Ñ<Ô<ˆAð Ô"×&Ò&Ñ(Ô(ñØØØØØØà�g�:Ðr!   r„   rb   s     r"   Ú"test_cancelConnectSSLFailedTimeoutz5ClientCreatorTests.test_cancelConnectSSLFailedTimeoutF  s'   € ð
	ð 
	ð 
	ð ×3Ò3°GÑ<Ô<Ð<r!   N)r   r   r   Ú__doc__r-   r=   rG   rP   r[   rc   rg   rj   ro   ru   ry   r}   r�   r…   r‰   rŒ   r    r!   r"   r   r   #   s  € € € € € ðð ð6ð 6ð 6ð,&ð &ð &ð$&ð &ð &ð"&ð &ð &ð:5ð 5ð 5ð,	0ð 	0ð 	0ð	0ð 	0ð 	0ð	0ð 	0ð 	0ð5ð 5ð 5ð67ð 7ð 7ð(7ð 7ð 7ð(7ð 7ð 7ð65ð 5ð 5ð2=ð =ð =ð=ð =ð =ð=ð =ð =ð =ð =r!   r   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚProtocolTestsz:
    Tests for L{twisted.internet.protocol.Protocol}.
    c                 óÂ   — t          ¦   «         }|                      t          t          |¦  «        ¦  «         |                      t          t          |¦  «        ¦  «         dS )zT
        L{Protocol} instances provide L{IProtocol} and L{ILoggingContext}.
        N)r   rD   r   r	   r   )r'   Úprotos     r"   Útest_interfaceszProtocolTests.test_interfaces`  sK   € õ ‘
”
ˆØ�Š�¥Y°Ñ6Ô6Ñ7Ô7Ð7Ø�Š�¥_°eÑ<Ô<Ñ=Ô=Ð=Ð=Ð=r!   c                 óŒ   —  G d„ dt           ¦  «        }|                      d |¦   «                              ¦   «         ¦  «         dS )zJ
        L{Protocol.logPrefix} returns the protocol class's name.
        c                   ó   — e Zd ZdS )ú/ProtocolTests.test_logPrefix.<locals>.SomeThingNr   r    r!   r"   Ú	SomeThingr•   m  r$   r!   r–   N)r   r6   Ú	logPrefix)r'   r–   s     r"   Útest_logPrefixzProtocolTests.test_logPrefixh  s\   € ð
	ð 	ð 	ð 	ð 	�ñ 	ô 	ð 	ð 	×Ò˜ i i¡k¤k×&;Ò&;Ñ&=Ô&=Ñ>Ô>Ð>Ð>Ð>r!   c                 ó¾   ‡— g Š G ˆfd„dt           ¦  «        }t          ¦   «         } |¦   «         }|                     |¦  «         |                      ‰|g¦  «         dS )zz
        L{Protocol.makeConnection} sets the given transport on itself, and
        then calls C{connectionMade}.
        c                   ó   •— e Zd Zˆ fd„ZdS )ú7ProtocolTests.test_makeConnection.<locals>.SomeProtocolc                 ó<   •— ‰                      | j        ¦  «         d S ©N)Úappendrs   )r'   Úresults    €r"   ÚconnectionMadezFProtocolTests.test_makeConnection.<locals>.SomeProtocol.connectionMadez  s   ø€ Ø—’˜dœnÑ-Ô-Ð-Ð-Ð-r!   N)r   r   r   r    ©rŸ   s   €r"   r#   r›   y  s.   ø€ € € € € ð.ð .ð .ð .ð .ð .ð .r!   r#   N)r   rJ   rr   r6   )r'   r#   rs   r,   rŸ   s       @r"   Útest_makeConnectionz!ProtocolTests.test_makeConnectionr  s†   ø€ ð
 ˆð	.ð 	.ð 	.ð 	.ð 	.ð 	.ð 	.�8ñ 	.ô 	.ð 	.õ ‘H”Hˆ	Ø�<‘>”>ˆØ×Ò 	Ñ*Ô*Ð*Ø×Ò˜ ) Ñ-Ô-Ð-Ð-Ð-r!   N)r   r   r   r�   r’   r˜   r¢   r    r!   r"   r�   r�   [  sK   € € € € € ðð ð>ð >ð >ð?ð ?ð ?ð.ð .ð .ð .ð .r!   r�   c                   ó6   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	dS )	ÚFactoryTestsz(
    Tests for L{protocol.Factory}.
    c                 óÂ   — t          ¦   «         }|                      t          t          |¦  «        ¦  «         |                      t          t          |¦  «        ¦  «         dS )zg
        L{Factory} instances provide both L{IProtocolFactory} and
        L{ILoggingContext}.
        N)r   rD   r   r
   r   )r'   r+   s     r"   r’   zFactoryTests.test_interfacesˆ  sL   € õ
 ‘)”)ˆØ�Š�Õ%5°wÑ?Ô?Ñ@Ô@Ð@Ø�Š�¥_°gÑ>Ô>Ñ?Ô?Ð?Ð?Ð?r!   c                 óŒ   —  G d„ dt           ¦  «        }|                      d |¦   «                              ¦   «         ¦  «         dS )zM
        L{Factory.logPrefix} returns the name of the factory class.
        c                   ó   — e Zd ZdS )ú6FactoryTests.test_logPrefix.<locals>.SomeKindOfFactoryNr   r    r!   r"   ÚSomeKindOfFactoryr¨   –  r$   r!   r©   N)r   r6   r—   )r'   r©   s     r"   r˜   zFactoryTests.test_logPrefix‘  sa   € ð
	ð 	ð 	ð 	ð 	¥ñ 	ô 	ð 	ð 	×ÒÐ,Ð.?Ð.?Ñ.AÔ.A×.KÒ.KÑ.MÔ.MÑNÔNÐNÐNÐNr!   c                 óâ   —  G d„ dt           ¦  «        }t          ¦   «         }||_        |                     d¦  «        }|                      ||¦  «         |                      |j        |¦  «         dS )z¡
        L{Factory.buildProtocol} by default constructs a protocol by calling
        its C{protocol} attribute, and attaches the factory to the result.
        c                   ó   — e Zd ZdS )ú<FactoryTests.test_defaultBuildProtocol.<locals>.SomeProtocolNr   r    r!   r"   r#   r¬   ¡  r$   r!   r#   N)r   r   r,   r%   r&   rM   r+   )r'   r#   Úfr,   s       r"   Útest_defaultBuildProtocolz&FactoryTests.test_defaultBuildProtocol›  s‚   € ð	ð 	ð 	ð 	ð 	�8ñ 	ô 	ð 	õ ‰IŒIˆØ!ˆŒ
Ø—?’? 4Ñ(Ô(ˆØ×Ò˜h¨Ñ5Ô5Ð5Ø�Š�hÔ&¨Ñ*Ô*Ð*Ð*Ð*r!   c                 ó  —  G d„ dt           ¦  «        }|                     t          ddd¬¦  «        }|                      |j        t          ¦  «         |                      |j        d¦  «         |                      |j        ddi¦  «         d	S )
z¹
        L{Factory.forProtocol} constructs a Factory, passing along any
        additional arguments, and sets its C{protocol} attribute to the given
        Protocol subclass.
        c                   ó   — e Zd Zd„ ZdS )ú7FactoryTests.test_forProtocol.<locals>.ArgTakingFactoryc                 ó$   — ||c| _         | _        d S r�   )ÚargsÚkwargs)r'   r³   r´   s      r"   Ú__init__z@FactoryTests.test_forProtocol.<locals>.ArgTakingFactory.__init__²  s   € Ø)-¨vÐ&�”	˜4œ;˜;˜;r!   N)r   r   r   rµ   r    r!   r"   ÚArgTakingFactoryr±   ±  s#   € € € € € ð6ð 6ð 6ð 6ð 6r!   r¶   rl   é   é   )Úfoo)rl   r·   r¹   N)r   ÚforProtocolr   r6   r,   r³   r´   )r'   r¶   r+   s      r"   Útest_forProtocolzFactoryTests.test_forProtocolª  s�   € ð	6ð 	6ð 	6ð 	6ð 	6�wñ 	6ô 	6ð 	6ð #×.Ò.­x¸¸AÀ2Ð.ÑFÔFˆØ×Ò˜Ô)­8Ñ4Ô4Ð4Ø×Ò˜œ vÑ.Ô.Ð.Ø×Ò˜œ¨%°¨Ñ5Ô5Ð5Ð5Ð5r!   c                 ó’  ‡— g Št          j        ‰j        ¦  «         |                      ˆfd„¦  «         t	          ¦   «         }|                     ¦   «          |                      ‰d         d         |¦  «         |                      ‰d         d         t          j	        ¦  «         |                      ‰d         d         d¦  «         dS )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                  ó6   •— t          j        ‰ j        ¦  «        S r�   ©r   ÚremoveObserverrž   ©Úeventss   €r"   ú<lambda>z;FactoryTests.test_doStartLoggingStatement.<locals>.<lambda>Á  ó   ø€ Õ 2Ô AÀ&Ä-Ñ PÔ P€ r!   r   r+   Ú	log_levelÚ
log_formatzStarting factory {factory!r}N)
r   ÚaddObserverrž   Ú
addCleanupr   ÚdoStartrM   r6   r   Úinfo)r'   r­   rÁ   s     @r"   Útest_doStartLoggingStatementz)FactoryTests.test_doStartLoggingStatementº  s³   ø€ ð
 ˆÝÔ& v¤}Ñ5Ô5Ð5Ø�ŠÐPÐPÐPÐPÑQÔQÐQå‰IŒIˆØ	�	Š	‰Œˆà�Š�f˜Q”i 	Ô*¨AÑ.Ô.Ð.Ø×Ò˜ œ ;Ô/µ´Ñ?Ô?Ð?Ø×Ò˜ œ <Ô0Ð2PÑQÔQÐQÐQÐQr!   c                 ó°  ‡— g Št          j        ‰j        ¦  «         |                      ˆfd„¦  «          G d„ dt          ¦  «        } |¦   «         }|                     ¦   «          |                      ‰d         d         |¦  «         |                      ‰d         d         t          j	        ¦  «         |                      ‰d         d         d¦  «         d	S )
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                  ó6   •— t          j        ‰ j        ¦  «        S r�   r¾   rÀ   s   €r"   rÂ   z:FactoryTests.test_doStopLoggingStatement.<locals>.<lambda>Ñ  rÃ   r!   c                   ó   — e Zd ZdZdS )ú;FactoryTests.test_doStopLoggingStatement.<locals>.MyFactoryrl   N)r   r   r   ÚnumPortsr    r!   r"   Ú	MyFactoryrÎ   Ó  s   € € € € € ØˆHˆHˆHr!   rÐ   r   r+   rÄ   rÅ   zStopping factory {factory!r}N)
r   rÆ   rž   rÇ   r   ÚdoStoprM   r6   r   rÉ   )r'   rÐ   r­   rÁ   s      @r"   Útest_doStopLoggingStatementz(FactoryTests.test_doStopLoggingStatementÊ  sá   ø€ ð
 ˆÝÔ& v¤}Ñ5Ô5Ð5Ø�ŠÐPÐPÐPÐPÑQÔQÐQð	ð 	ð 	ð 	ð 	�ñ 	ô 	ð 	ð ˆI‰KŒKˆØ	�Š‰
Œ
ˆ
à�Š�f˜Q”i 	Ô*¨AÑ.Ô.Ð.Ø×Ò˜ œ ;Ô/µ´Ñ?Ô?Ð?Ø×Ò˜ œ <Ô0Ð2PÑQÔQÐQÐQÐQr!   N)
r   r   r   r�   r’   r˜   r®   r»   rÊ   rÒ   r    r!   r"   r¤   r¤   ƒ  s†   € € € € € ðð ð@ð @ð @ðOð Oð Oð+ð +ð +ð6ð 6ð 6ð Rð Rð Rð Rð Rð Rð Rð Rr!   r¤   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚAdapterTestszR
    Tests for L{ProtocolToConsumerAdapter} and L{ConsumerToProtocolAdapter}.
    c                 óê   — g }t          ¦   «         }|j        |_        t          |¦  «        }|                     d¦  «         |                      |dg¦  «         |                      |t          ¦  «         dS )z}
        L{IProtocol} providers can be adapted to L{IConsumer} providers using
        L{ProtocolToConsumerAdapter}.
        ó   helloN)r   rž   ÚdataReceivedr   Úwriter6   r&   r   )r'   rŸ   ÚpÚconsumers       r"   Útest_protocolToConsumerz$AdapterTests.test_protocolToConsumerã  sm   € ð
 ˆÝ‰JŒJˆØœˆŒÝ˜Q‘<”<ˆØ�Š�xÑ Ô Ð Ø×Ò˜ ( Ñ,Ô,Ð,Ø×Ò˜hÕ(AÑBÔBÐBÐBÐBr!   c                 ó  ‡— g Št          t          ¦  «         G ˆfd„d¦  «        ¦   «         } |¦   «         }t          |¦  «        }|                     d¦  «         |                      ‰dg¦  «         |                      |t          ¦  «         dS )z}
        L{IConsumer} providers can be adapted to L{IProtocol} providers using
        L{ProtocolToConsumerAdapter}.
        c                   ó   •— e Zd Zˆ fd„ZdS )ú6AdapterTests.test_consumerToProtocol.<locals>.Consumerc                 ó2   •— ‰                      |¦  «         d S r�   )rž   )r'   rY   rŸ   s     €r"   rØ   z<AdapterTests.test_consumerToProtocol.<locals>.Consumer.writeù  s   ø€ Ø—’˜aÑ Ô Ð Ð Ð r!   N)r   r   r   rØ   r¡   s   €r"   ÚConsumerrÞ   ÷  s.   ø€ € € € € ð!ð !ð !ð !ð !ð !ð !r!   rà   rÖ   N)r   r   r	   r×   r6   r&   r   )r'   rà   Úcr,   rŸ   s       @r"   Útest_consumerToProtocolz$AdapterTests.test_consumerToProtocolð  s°   ø€ ð
 ˆå	•YÑ	Ô	ð	!ð 	!ð 	!ð 	!ð 	!ð 	!ð 	!ñ 	!ô 	!ñ 
 Ô	ð	!ð ˆH‰JŒJˆÝ˜Q‘<”<ˆØ×Ò˜hÑ'Ô'Ð'Ø×Ò˜ ( Ñ,Ô,Ð,Ø×Ò˜hÕ(AÑBÔBÐBÐBÐBr!   N)r   r   r   r�   rÛ   râ   r    r!   r"   rÔ   rÔ   Þ  sD   € € € € € ðð ðCð Cð CðCð Cð Cð Cð Cr!   rÔ   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚFileWrapperTestsz2
    L{twisted.internet.protocol.FileWrapper}
    c                 óz  — t          t          ¦   «         ¦  «        }|                     d¦  «         |                      |j                             ¦   «         d¦  «         t          t          ¦   «         ¦  «        }|                     d¦  «         |                      |j                             ¦   «         d¦  «         dS )z@
        L{twisted.internet.protocol.FileWrapper.write}
        ó   test1ÚstuffN)r   r   rØ   r6   ÚfileÚgetvalueÚassertNotEqual©r'   Úwrappers     r"   Ú
test_writezFileWrapperTests.test_write  sš   € õ �g™iœiÑ(Ô(ˆØ�Š�hÑÔÐØ×Ò˜œ×.Ò.Ñ0Ô0°(Ñ;Ô;Ð;å�g™iœiÑ(Ô(ˆð 	�Š�gÑÔÐØ×Ò˜GœL×1Ò1Ñ3Ô3°WÑ=Ô=Ð=Ð=Ð=r!   c                 ó@  — t          t          ¦   «         ¦  «        }|                     ddg¦  «         |                      |j                             ¦   «         d¦  «         t          t          ¦   «         ¦  «        }|                      t          |j        ddg¦  «         dS )zH
        L{twisted.internet.protocol.FileWrapper.writeSequence}
        ræ   s   test2s
   test1test2Útest3Útest4N)r   r   ÚwriteSequencer6   rè   ré   ÚassertRaisesÚ	TypeErrorrë   s     r"   Útest_writeSequencez#FileWrapperTests.test_writeSequence  s‰   € õ �g™iœiÑ(Ô(ˆØ×Ò˜x¨Ð2Ñ3Ô3Ð3Ø×Ò˜œ×.Ò.Ñ0Ô0°-Ñ@Ô@Ð@å�g™iœiÑ(Ô(ˆà×Ò�) WÔ%:¸WÀgÐ<NÑOÔOÐOÐOÐOr!   N)r   r   r   r�   rí   rô   r    r!   r"   rä   rä     sA   € € € € € ðð ð>ð >ð >ð
Pð 
Pð 
Pð 
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>rÿ      sF  ððð ð
 Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &Ø .Ð .Ð .Ð .Ð .Ð .à 1Ð 1Ð 1Ð 1Ð 1Ð 1ðð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð IÐ HÐ HÐ HÐ HÐ HÐ HÐ HØ 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø *Ð *Ð *Ð *Ð *Ð *Ø +Ð +Ð +Ð +Ð +Ð +ðu=ð u=ð u=ð u=ð u=˜ñ u=ô u=ð u=ðp	%.ð %.ð %.ð %.ð %.�Hñ %.ô %.ð %.ðPXRð XRð XRð XRð XR�8ñ XRô XRð XRðv"Cð "Cð "Cð "Cð "C�8ñ "Cô "Cð "CðJPð Pð Pð Pð P�xñ Pô Pð Pð Pð Pr!   