%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�fW&����dZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZmZmZdd	lmZGd
�de�Zee�Gd�d
��ZGd�de�ZGd�de�Zy)z"
Tests for L{twisted.test.iosim}.
�)�annotations)�Literal)�implementer)�
IPushProducer)�Protocol)�Clock)�
FakeTransport�connect�connectedServerAndClient)�TestCasec�(�eZdZdZdd�Zdd�Zdd�Zy)�FakeTransportTestsz%
    Tests for L{FakeTransport}.
    c� �tt�d�}tt�d�}|j|jt�|j|jt�|j|j|j�y)ze
        Each L{FakeTransport} receives a serial number that uniquely identifies
        it.
        TFN)r	�object�assertIsInstance�serial�int�assertNotEqual)�self�a�bs   �9/usr/lib/python3/dist-packages/twisted/test/test_iosim.py�test_connectionSerialz(FakeTransportTests.test_connectionSerials`��

�&�(�D�)���&�(�E�*�����a�h�h��,����a�h�h��,����A�H�H�a�h�h�/�c���tt�d�}|jd�|jgd��|j	dj|j�d�y)zl
        L{FakeTransport.writeSequence} will write a sequence of L{bytes} to the
        transport.
        F�a)�b�c�drsabcdN)r	r�write�
writeSequence�assertEqual�join�stream�rrs  r�test_writeSequencez%FakeTransportTests.test_writeSequence$sG��

�&�(�E�*��	����
�	���*�+�������!�(�(�+�W�5rc���tt�d�}|jd�|j�|jd�|j	dj|j�d�y)z�
        L{FakeTransport.write} will accept writes after transport was closed,
        but the data will be silently discarded.
        FsbeforesafterrN)r	rr �loseConnectionr"r#r$r%s  r�test_writeAfterClosez'FakeTransportTests.test_writeAfterClose0sS��

�&�(�E�*��	���	��	����	�����������!�(�(�+�Y�7rN��return�None)�__name__�
__module__�__qualname__�__doc__rr&r)�rrrrs���	0�
6�
8rrc�,�eZdZdZdZdd�Zdd�Zdd�Zy)�StrictPushProducerz�
    An L{IPushProducer} implementation which produces nothing but enforces
    preconditions on its state transition methods.
    �runningc�F�|jdk(rtd��d|_y)N�stoppedz)Cannot stop already-stopped IPushProducer��_state�
ValueError�rs r�
stopProducingz StrictPushProducer.stopProducingFs!���;�;�)�#��H�I�I���rc�b�|jdk7rtd|j�d���d|_y)Nr4z
Cannot pause � IPushProducer�pausedr7r:s r�pauseProducingz!StrictPushProducer.pauseProducingKs-���;�;�)�#��}�T�[�[�M��H�I�I���rc�b�|jdk7rtd|j�d���d|_y)Nr>zCannot resume r=r4r7r:s r�resumeProducingz"StrictPushProducer.resumeProducingPs-���;�;�(�"��~�d�k�k�]�.�I�J�J���rNr*)r-r.r/r0r8r;r?rAr1rrr3r3=s���
�F� �
�
 rr3c��eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
dd	�Zdd
�Zdd�Z
dd�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zy)�StrictPushProducerTestsz*
    Tests for L{StrictPushProducer}.
    c��t�S)zp
        @return: A new L{StrictPushProducer} which has not been through any state
            changes.
        )r3r:s r�_initialz StrictPushProducerTests._initial[s
��
"�#�#rc�:�t�}|j�|S)z@
        @return: A new, stopped L{StrictPushProducer}.
        )r3r;�r�producers  r�_stoppedz StrictPushProducerTests._stoppedbs��&�'����� ��rc�:�t�}|j�|S)z?
        @return: A new, paused L{StrictPushProducer}.
        )r3r?rGs  r�_pausedzStrictPushProducerTests._pausedjs��&�'�����!��rc�Z�t�}|j�|j�|S)zY
        @return: A new L{StrictPushProducer} which has been paused and resumed.
        )r3r?rArGs  r�_resumedz StrictPushProducerTests._resumedrs)��&�'�����!�� � �"��rc�<�|j|jd�y)z�
        Assert that the given producer is in the stopped state.

        @param producer: The producer to verify.
        @type producer: L{StrictPushProducer}
        r6N�r"r8rGs  r�
assertStoppedz%StrictPushProducerTests.assertStopped{���	
������)�4rc�<�|j|jd�y)z�
        Assert that the given producer is in the paused state.

        @param producer: The producer to verify.
        @type producer: L{StrictPushProducer}
        r>NrOrGs  r�assertPausedz$StrictPushProducerTests.assertPaused�s��	
������(�3rc�<�|j|jd�y)z�
        Assert that the given producer is in the running state.

        @param producer: The producer to verify.
        @type producer: L{StrictPushProducer}
        r4NrOrGs  r�
assertRunningz%StrictPushProducerTests.assertRunning�rQrc�`�|jt|j�j�y)zz
        L{StrictPushProducer.stopProducing} raises L{ValueError} if called when
        the producer is stopped.
        N)�assertRaisesr9rIr;r:s r�test_stopThenStopz)StrictPushProducerTests.test_stopThenStop�s ��
	
���*�d�m�m�o�&C�&C�Drc�`�|jt|j�j�y)z{
        L{StrictPushProducer.pauseProducing} raises L{ValueError} if called when
        the producer is stopped.
        N)rWr9rIr?r:s r�test_stopThenPausez*StrictPushProducerTests.test_stopThenPause�s ��
	
���*�d�m�m�o�&D�&D�Erc�`�|jt|j�j�y)z|
        L{StrictPushProducer.resumeProducing} raises L{ValueError} if called when
        the producer is stopped.
        N)rWr9rIrAr:s r�test_stopThenResumez+StrictPushProducerTests.test_stopThenResume�s ��
	
���*�d�m�m�o�&E�&E�Frc�f�|j�}|j�|j|�y)zn
        L{StrictPushProducer} is stopped if C{stopProducing} is called on a paused
        producer.
        N)rKr;rPrGs  r�test_pauseThenStopz*StrictPushProducerTests.test_pauseThenStop�s)��
�<�<�>����� ����8�$rc�d�|j�}|jt|j�y)zs
        L{StrictPushProducer.pauseProducing} raises L{ValueError} if called on a
        paused producer.
        N)rKrWr9r?rGs  r�test_pauseThenPausez+StrictPushProducerTests.test_pauseThenPause�s%��
�<�<�>�����*�h�&=�&=�>rc�f�|j�}|j�|j|�y)zp
        L{StrictPushProducer} is resumed if C{resumeProducing} is called on a
        paused producer.
        N)rKrArUrGs  r�test_pauseThenResumez,StrictPushProducerTests.test_pauseThenResume�s)��
�<�<�>��� � �"����8�$rc�f�|j�}|j�|j|�y)zo
        L{StrictPushProducer} is stopped if C{stopProducing} is called on a
        resumed producer.
        N)rMr;rPrGs  r�test_resumeThenStopz+StrictPushProducerTests.test_resumeThenStop��)��
�=�=�?����� ����8�$rc�f�|j�}|j�|j|�y)zo
        L{StrictPushProducer} is paused if C{pauseProducing} is called on a
        resumed producer.
        N)rMr?rSrGs  r�test_resumeThenPausez,StrictPushProducerTests.test_resumeThenPause��)��
�=�=�?�����!����(�#rc�d�|j�}|jt|j�y)zu
        L{StrictPushProducer.resumeProducing} raises L{ValueError} if called on a
        resumed producer.
        N)rMrWr9rArGs  r�test_resumeThenResumez-StrictPushProducerTests.test_resumeThenResume��%��
�=�=�?�����*�h�&>�&>�?rc�f�|j�}|j�|j|�y)zn
        L{StrictPushProducer} is stopped if C{stopProducing} is called in the
        initial state.
        N)rEr;rPrGs  r�	test_stopz!StrictPushProducerTests.test_stop�rerc�f�|j�}|j�|j|�y)zn
        L{StrictPushProducer} is paused if C{pauseProducing} is called in the
        initial state.
        N)rEr?rSrGs  r�
test_pausez"StrictPushProducerTests.test_pause�rhrc�d�|j�}|jt|j�y)zz
        L{StrictPushProducer} raises L{ValueError} if C{resumeProducing} is called
        in the initial state.
        N)rErWr9rArGs  r�test_resumez#StrictPushProducerTests.test_resume�rkrN)r+r3)rHr3r+r,r*)r-r.r/r0rErIrKrMrPrSrUrXrZr\r^r`rbrdrgrjrmrorqr1rrrCrCVsk���$����5�4�5�E�F�G�%�?�%�%�$�@�%�$�@rrCc�0�eZdZdZdd�Zdd�Zdd�Zdd�Zy)	�IOPumpTestsz
    Tests for L{IOPump}.
    c�"�t�}t|d��}t�}t|d��}t||||d��}t�}||d�|}|j	|d��|j�|j
d|j�y)	a�
        Connect a couple protocol/transport pairs to an L{IOPump} and then pump
        it.  Verify that a streaming producer registered with one of the
        transports does not receive invalid L{IPushProducer} method calls and
        ends in the right state.

        @param mode: C{u"server"} to test a producer registered with the
            server transport.  C{u"client"} to test a producer registered with
            the client transport.
        T)�isServerF)�greet)�server�client)�	streamingr4N)rr	r
r3�registerProducer�pumpr"r8)	r�mode�serverProto�serverTransport�clientProto�clientTransportr{rH�victims	         r�_testStreamingProducerz"IOPumpTests._testStreamingProducer�s����j��'��d�C���j��'��e�D��������
��&�'��%�%�
����	����D��9��	�	������H�O�O�4rc�(�|jd��y)z�
        L{IOPump.pump} does not call C{resumeProducing} on a L{IPushProducer}
        (stream producer) registered with the server transport.
        rw�r|N�r�r:s r�test_serverStreamingProducerz(IOPumpTests.test_serverStreamingProducer"���
	
�#�#��#�2rc�(�|jd��y)z�
        L{IOPump.pump} does not call C{resumeProducing} on a L{IPushProducer}
        (stream producer) registered with the client transport.
        rxr�Nr�r:s r�test_clientStreamingProducerz(IOPumpTests.test_clientStreamingProducer)r�rc����g�t�}ttt|��\}}}|jd�fd��|j	��|j�|j
��y)zE
        L{IOPump.pump} advances time in the given L{Clock}.
        )�clockrc�&���jd�S)NT)�append)�time_passeds�r�<lambda>z/IOPumpTests.test_timeAdvances.<locals>.<lambda>7s���;�#5�#5�d�#;�rN)rrr�	callLater�assertFalser{�
assertTrue)rr��_r{r�s    @r�test_timeAdvanceszIOPumpTests.test_timeAdvances0sW��������-�h���N�
��1�d�
����;�<�����%��	�	������$rN)r|zLiteral['server', 'client']r+r,r*)r-r.r/r0r�r�r�r�r1rrrsrs�s���!5�F3�3�
%rrsN)r0�
__future__r�typingr�zope.interfacer�twisted.internet.interfacesr�twisted.internet.protocolr�twisted.internet.taskr�twisted.test.iosimr	r
r�twisted.trial.unittestrrr3rCrsr1rr�<module>r�sq���#��&�5�.�'�O�O�+�&8��&8�R
�]�� � �� �0a@�h�a@�H@%�(�@%r

Zerion Mini Shell 1.0