%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/internet/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/internet/test/__pycache__/test_testing.cpython-312.pyc

�

Ϫ�f�A��2�dZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZmZddlmZmZdd	lmZmZmZmZdd
lmZddlmZGd�d
e�Z Gd�de�Z!Gd�d�Z"Gd�de�Z#Gd�de�Z$Gd�de�Z%y)z(
Tests for L{twisted.internet.testing}.
�)�annotations)�Callable)�verifyObject)�Protocol)�IPv4Address)	�IAddress�
IConnector�	IConsumer�IListeningPort�
IPushProducer�IReactorSSL�IReactorTCP�IReactorUNIX�
ITransport)�
ClientFactory�Factory)�
MemoryReactor�NonStreamingProducer�RaisingMemoryReactor�StringTransport)�namedAny)�TestCasec��eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dd	�Zdd
�Zdd�Z
dd�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zy)�StringTransportTestsz@
    Tests for L{twisted.internet.testing.StringTransport}.
    c�"�t�|_y�N)r�	transport��selfs �D/usr/lib/python3/dist-packages/twisted/internet/test/test_testing.py�setUpzStringTransportTests.setUp+s��(�*���c��|jtt|j��|jtt|j��|jtt
|j��y)zq
        L{StringTransport} instances provide L{ITransport}, L{IPushProducer},
        and L{IConsumer}.
        N)�
assertTruerrrrr
rs r �test_interfacesz$StringTransportTests.test_interfaces.sI��
	
����Z����@�A�����]�D�N�N�C�D�����Y����?�@r"c��t�}t�}|jj||�|j|jj|�|j|jj
|�y)zz
        L{StringTransport.registerProducer} records the arguments supplied to
        it as instance attributes.
        N)�objectr�registerProducer�assertIs�producer�	streaming�rr*r+s   r �test_registerProducerz*StringTransportTests.test_registerProducer7sV��
�8���H�	����'�'��)�<��
�
�d�n�n�-�-�x�8��
�
�d�n�n�.�.�	�:r"c�N�t�}|jj|d�|jt|jjt�d�|j|jj|�|j|jj�y)zy
        L{StringTransport.registerProducer} raises L{RuntimeError} if a
        producer is already registered.
        TFN)	r'rr(�assertRaises�RuntimeErrorr)r*r$r+)rr*s  r �test_disallowedRegisterProducerz4StringTransportTests.test_disallowedRegisterProducerBsr��
�8�����'�'��$�7�����$�.�.�9�9�6�8�U�	
�	
�
�
�d�n�n�-�-�x�8�������0�0�1r"c��t�}t�}|jj|d�|jj�|j	|jj
�|jj|d�|j
|jj
|�|j|jj�y)z�
        L{StringTransport.unregisterProducer} causes the transport to forget
        about the registered producer and makes it possible to register a new
        one.
        FTN)	r'rr(�unregisterProducer�assertIsNoner*r)r$r+)r�oldProducer�newProducers   r �test_unregisterProducerz,StringTransportTests.test_unregisterProducerOs����h���h�����'�'��U�;����)�)�+����$�.�.�1�1�2����'�'��T�:��
�
�d�n�n�-�-�{�;�������0�0�1r"c�X�|jt|jj�y)z�
        L{StringTransport.unregisterProducer} raises L{RuntimeError} if called
        when no producer is registered.
        N)r/r0rr3rs r �test_invalidUnregisterProducerz3StringTransportTests.test_invalidUnregisterProducer^s��
	
���,����(I�(I�Jr"c�P�|j|jjd�y)zO
        L{StringTransport.producerState} is initially C{'producing'}.
        �	producingN)�assertEqualr�
producerStaters r �test_initialProducerStatez.StringTransportTests.test_initialProducerStatees��	
������5�5�{�Cr"c��|jj�|j|jjd�y)zy
        L{StringTransport.pauseProducing} changes the C{producerState} of the
        transport to C{'paused'}.
        �pausedN)r�pauseProducingr<r=rs r �test_pauseProducingz(StringTransportTests.test_pauseProducingks.��
	
���%�%�'�������5�5�x�@r"c��|jj�|jj�|j|jjd�y)z}
        L{StringTransport.resumeProducing} changes the C{producerState} of the
        transport to C{'producing'}.
        r;N)rrA�resumeProducingr<r=rs r �test_resumeProducingz)StringTransportTests.test_resumeProducingss>��
	
���%�%�'����&�&�(�������5�5�{�Cr"c��|jj�|j|jjd�y)z{
        L{StringTransport.stopProducing} changes the C{'producerState'} of the
        transport to C{'stopped'}.
        �stoppedN)r�
stopProducingr<r=rs r �test_stopProducingz'StringTransportTests.test_stopProducing|s.��
	
���$�$�&�������5�5�y�Ar"c��|jj�|jt|jj�y)zu
        L{StringTransport.pauseProducing} raises L{RuntimeError} if the
        transport has been stopped.
        N)rrHr/r0rArs r � test_stoppedTransportCannotPausez5StringTransportTests.test_stoppedTransportCannotPause�s.��
	
���$�$�&����,����(E�(E�Fr"c��|jj�|jt|jj�y)zv
        L{StringTransport.resumeProducing} raises L{RuntimeError} if the
        transport has been stopped.
        N)rrHr/r0rDrs r �!test_stoppedTransportCannotResumez6StringTransportTests.test_stoppedTransportCannotResume�s.��
	
���$�$�&����,����(F�(F�Gr"c��|jj�|jt|jj�y)zz
        L{StringTransport.pauseProducing} raises L{RuntimeError} if the
        transport is being disconnected.
        N)r�loseConnectionr/r0rArs r �&test_disconnectingTransportCannotPausez;StringTransportTests.test_disconnectingTransportCannotPause�s.��
	
���%�%�'����,����(E�(E�Fr"c��|jj�|jt|jj�y)z{
        L{StringTransport.resumeProducing} raises L{RuntimeError} if the
        transport is being disconnected.
        N)rrOr/r0rDrs r �'test_disconnectingTransportCannotResumez<StringTransportTests.test_disconnectingTransportCannotResume�s.��
	
���%�%�'����,����(F�(F�Gr"c���|j|jj�|jj�|j	|jj�y)zv
        L{StringTransport.loseConnection} toggles the C{disconnecting} instance
        variable to C{True}.
        N)�assertFalser�
disconnectingrOr$rs r �$test_loseConnectionSetsDisconnectingz9StringTransportTests.test_loseConnectionSetsDisconnecting�sB��
	
������5�5�6����%�%�'�������4�4�5r"c�j�t�}|jt|�j�|�y)z�
        If a host address is passed to L{StringTransport.__init__}, that
        value is returned from L{StringTransport.getHost}.
        N)r'r)r�getHost�r�addresss  r �test_specifiedHostAddressz.StringTransportTests.test_specifiedHostAddress�s'��
�(���
�
�o�g�.�6�6�8�'�Br"c�l�t�}|jt|��j�|�y)z�
        If a peer address is passed to L{StringTransport.__init__}, that
        value is returned from L{StringTransport.getPeer}.
        )�peerAddressN)r'r)r�getPeerrYs  r �test_specifiedPeerAddressz.StringTransportTests.test_specifiedPeerAddress�s'��
�(���
�
�o�'�:�B�B�D�g�Nr"c�`�t�j�}|j|t�y)z�
        If no host address is passed to L{StringTransport.__init__}, an
        L{IPv4Address} is returned from L{StringTransport.getHost}.
        N)rrX�assertIsInstancerrYs  r �test_defaultHostAddressz,StringTransportTests.test_defaultHostAddress��%��
"�#�+�+�-�����g�{�3r"c�`�t�j�}|j|t�y)z�
        If no peer address is passed to L{StringTransport.__init__}, an
        L{IPv4Address} is returned from L{StringTransport.getPeer}.
        N)rr^rarrYs  r �test_defaultPeerAddressz,StringTransportTests.test_defaultPeerAddress�rcr"N��return�None)�__name__�
__module__�__qualname__�__doc__r!r%r-r1r7r9r>rBrErIrKrMrPrRrVr[r_rbre�r"r rr&sr���+�A�	;�2�
2�K�D�A�D�B�G�H�G�H�6�C�O�4�4r"rc�@�eZdZdZd	d�Zd	d�Zd	d�Zd	d�Zd	d�Zd	d�Z	y)
�ReactorTestszA
    Tests for L{MemoryReactor} and L{RaisingMemoryReactor}.
    c�x�t�}tt|�tt|�tt|�y)zt
        L{MemoryReactor} provides all of the attributes described by the
        interfaces it advertises.
        N)rrrr
r)r�
memoryReactors  r �test_memoryReactorProvidesz'ReactorTests.test_memoryReactorProvides�s)��
&��
��[�-�0��[�-�0��\�=�1r"c�x�t�}tt|�tt|�tt|�y)z{
        L{RaisingMemoryReactor} provides all of the attributes described by the
        interfaces it advertises.
        N)rrrr
r)r�raisingReactors  r �test_raisingReactorProvidesz(ReactorTests.test_raisingReactorProvides�s*��
.�/���[�.�1��[�.�1��\�>�2r"c�,�t�}|jddt��|jddt�d�fD]j}t	t
|�|j
�}t	t|�|j|jd�|j|jd��l|jdt��}t	t
|�|j
�}t	t|�|j|jd�y)a
        L{MemoryReactor.connectTCP}, L{MemoryReactor.connectSSL}, and
        L{MemoryReactor.connectUNIX} will return an L{IConnector} whose
        C{getDestination} method returns an L{IAddress} with attributes which
        reflect the values passed.
        ztest.example.comi� Ns
/fake/path)
r�
connectTCPr�
connectSSLrr	�getDestinationrr<�host�port�connectUNIX�name)rrq�	connectorrZs    r �test_connectDestinationz$ReactorTests.test_connectDestination�s���&��
��$�$�%7��}��O��$�$�%7��}��PT�U�
�	1�I�
��Y�/��.�.�0�G���7�+����W�\�\�+=�>����W�\�\�4�0�	1�"�-�-�m�]�_�M�	��Z��+��*�*�,���X�w�'�������}�5r"c�(�t�}|jdt��|jdt�d�fD]j}t	t
|�|j
�}t	t|�|j|jd�|j|jd��l|jdt��}t	t
|�|j
�}t	t|�|j|jd�y)a�
        L{MemoryReactor.listenTCP}, L{MemoryReactor.listenSSL} and
        L{MemoryReactor.listenUNIX} will return an L{IListeningPort} whose
        C{getHost} method returns an L{IAddress}; C{listenTCP} and C{listenSSL}
        will have a default host of C{'0.0.0.0'}, and a port that reflects the
        value passed, and C{listenUNIX} will have a name that reflects the path
        passed.
        i2 Nz0.0.0.0s/path/to/socket)
r�	listenTCPr�	listenSSLrrrXrr<rzr{�
listenUNIXr})rrqr{rZs    r �test_listenDefaultHostz#ReactorTests.test_listenDefaultHost�s���&��
��#�#�D�'�)�4��#�#�D�'�)�T�:�
�	1�D�
���.��l�l�n�G���7�+����W�\�\�9�5����W�\�\�4�0�	1��'�'�(:�G�I�F���^�T�*��,�,�.���X�w�'�������'9�:r"c��t�}t�}|j|�|j|�|j|j	�|g�|j|�|j|j	�g�y)z>
        Adding, removing, and listing readers works.
        N)r'r�	addReaderr<�
getReaders�removeReader)r�reader�reactors   r �test_readerszReactorTests.test_readers�p������/�����&�!����&�!�����+�+�-��x�8����V�$�����+�+�-�r�2r"c��t�}t�}|j|�|j|�|j|j	�|g�|j|�|j|j	�g�y)z>
        Adding, removing, and listing writers works.
        N)r'r�	addWriterr<�
getWriters�removeWriter)r�writerr�s   r �test_writerszReactorTests.test_writers'r�r"Nrf)
rirjrkrlrrrurr�r�r�rmr"r roro�s%���2�3�6�.;�23� 3r"roc�0�eZdZdZdd�Zdd�Zdd�Zd	d�Zy)
�TestConsumerzP
    A very basic test consumer for use with the NonStreamingProducerTests.
    c�.�g|_d|_d|_yr)�writesr*�producerStreamingrs r �__init__zTestConsumer.__init__=s��#%��� $��
�.2��r"c� �||_||_y)z�
        Registers a single producer with this consumer. Just keeps track of it.

        @param producer: The producer to register.
        @param streaming: Whether the producer is a streaming one or not.
        N�r*r�r,s   r r(zTestConsumer.registerProducerBs��!��
�!*��r"c� �d|_d|_y)zC
        Forget the producer we had previously registered.
        Nr�rs r r3zTestConsumer.unregisterProducerLs����
�!%��r"c�:�|jj|�y)zz
        Some data was written to the consumer: stores it for later use.

        @param data: The data to write.
        N)r��append)r�datas  r �writezTestConsumer.writeSs��	
�����4� r"Nrf)r*r'r+�boolrgrh)r��bytesrgrh)rirjrkrlr�r(r3r�rmr"r r�r�8s���3�
+�&�!r"r�c� �eZdZdZdd�Zdd�Zy)�NonStreamingProducerTestszF
    Tests for the L{NonStreamingProducer} to validate behaviour.
    c�Z�t�}t|�}|j|d�|j|j|�|j|j
|�|j
|j�td�D]}|j��gd�}|j|j�|j|j�|j|j
�|j|j|�|jt|j�y)z�
        When the L{NonStreamingProducer} has resumeProducing called 10 times,
        it writes the counter each time and then fails.
        F�
)
�0�1�2�3�4�5�6�7�8�9N)r�rr(r)r*�consumerrTr��rangerDr4r<r�r/r0)rr�r*�_�expectedWritess     r �test_producesOnly10Timesz2NonStreamingProducerTests.test_producesOnly10Timesas���
 �>��'��1���!�!�(�E�2��
�
�h�'�'��2��
�
�h�'�'��2�����3�3�4��r��	'�A��$�$�&�	'�V�����(�+�+�,����(�4�4�5����(�+�+�,�������.�9�	
���,��(@�(@�Ar"c��t�}t|�}|j|d�|j�|j	t
|j�y)zb
        When the L{NonStreamingProducer} is paused, it raises a
        L{RuntimeError}.
        FN)r�rr(rDr/r0rA)rr�r*s   r �test_cannotPauseProductionz4NonStreamingProducerTests.test_cannotPauseProduction{sI��
 �>��'��1���!�!�(�E�2�	� � �"����,��(?�(?�@r"Nrf)rirjrkrlr�r�rmr"r r�r�\s���B�4Ar"r�c��eZdZedd��Zy)�
_SupportsNamec��yrrmrs r riz_SupportsName.__name__�s��r"N)rg�str)rirjrk�propertyrmr"r r�r��s��
���r"r�c��eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dd	�Zdd
�Zdd�Z
dd�Zdd
�Zdd�Zdd�Zdd�Zy)�DeprecationTestsz8
    Deprecations in L{twisted.test.proto_helpers}.
    c��d|j��}|j|g�}|jt|dd�|jdt	|��|j||dd�|j
|t|��y)Nztwisted.internet.testing.r�category��message)ri�
flushWarningsr<�DeprecationWarning�len�assertInr)r)r�test�obj�new_path�warningss     r �helperzDeprecationTests.helper�s|��.�s�|�|�n�=���%�%�t�f�-�����+�X�a�[��-D�E�����C��M�*��
�
�h����I� 6�7��
�
�c�8�H�-�.r"c�H�ddlm}|j|j|�y)Nr)�AccumulatingProtocol)�twisted.test.proto_helpersr�r��test_accumulatingProtocol)rr�s  r r�z*DeprecationTests.test_accumulatingProtocol����C����D�2�2�4H�Ir"c�H�ddlm}|j|j|�y)Nr)�LineSendingProtocol)r�r�r��test_lineSendingProtocol)rr�s  r r�z)DeprecationTests.test_lineSendingProtocol�s��B����D�1�1�3F�Gr"c�H�ddlm}|j|j|�y)Nr)�FakeDatagramTransport)r�r�r��test_fakeDatagramTransport)rr�s  r r�z+DeprecationTests.test_fakeDatagramTransport�s��D����D�3�3�5J�Kr"c�H�ddlm}|j|j|�y)Nr)r)r�rr��test_stringTransport)rrs  r r�z%DeprecationTests.test_stringTransport�s��>����D�-�-��?r"c�H�ddlm}|j|j|�y)Nr)� StringTransportWithDisconnection)r�r�r��%test_stringTransportWithDisconnection)rr�s  r r�z6DeprecationTests.test_stringTransportWithDisconnection�s��O�����6�6�8X�	
r"c�H�ddlm}|j|j|�y)Nr)�StringIOWithoutClosing)r�r�r��test_stringIOWithoutClosing)rr�s  r r�z,DeprecationTests.test_stringIOWithoutClosing�s��E����D�4�4�6L�Mr"c�H�ddlm}|j|j|�y)Nr)�_FakeConnector)r�r�r��test__fakeConnector)rr�s  r r�z$DeprecationTests.test__fakeConnector�s��=����D�,�,�n�=r"c�H�ddlm}|j|j|�y)Nr)�	_FakePort)r�r�r��test__fakePort)rr�s  r r�zDeprecationTests.test__fakePort�s��8����D�'�'��3r"c�H�ddlm}|j|j|�y)Nr)r)r�rr��test_memoryReactor)rrs  r r�z#DeprecationTests.test_memoryReactor�s��<����D�+�+�]�;r"c�H�ddlm}|j|j|�y)Nr)�MemoryReactorClock)r�r�r��test_memoryReactorClock)rr�s  r r�z(DeprecationTests.test_memoryReactorClock�s��A����D�0�0�2D�Er"c�H�ddlm}|j|j|�y)Nr)r)r�rr��test_raisingMemoryReactor)rrs  r r�z*DeprecationTests.test_raisingMemoryReactor�r�r"c�H�ddlm}|j|j|�y)Nr)r)r�rr��test_nonStreamingProducer)rrs  r r�z*DeprecationTests.test_nonStreamingProducer�r�r"c�H�ddlm}|j|j|�y)Nr)�waitUntilAllDisconnected)r�r�r��test_waitUntilAllDisconnected)rr�s  r r�z.DeprecationTests.test_waitUntilAllDisconnected�s��G����D�6�6�8P�Qr"c�H�ddlm}|j|j|�y)Nr)�EventLoggingObserver)r�r�r��test_eventLoggingObserver)rr�s  r r�z*DeprecationTests.test_eventLoggingObserver�r�r"N)r�zCallable[..., object]r�r�rgrhrf)rirjrkrlr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rmr"r r�r��s\���/�J�
H�
L�
@�

�N�
>�
4�
<�
F�
J�
J�
R�
Jr"r�N)&rl�
__future__r�typingr�zope.interface.verifyrr�twisted.internet.addressr�twisted.internet.interfacesrr	r
rrr
rrr�twisted.internet.protocolrr�twisted.internet.testingrrrr�twisted.python.reflectr�twisted.trial.unittestrrror�r�r�r�rmr"r �<module>r�s����#��.��0�
�
�
�=���,�+�e4�8�e4�Pg3�8�g3�T!!�!!�H+A��+A�\�H��SJ�x�SJr"

Zerion Mini Shell 1.0