HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/test/__pycache__/test_iosim.cpython-38.pyc
U


W[d#�@s�dZddlmZmZddlmZddlmZddlm	Z	ddl
mZmZddl
mZGdd	�d	e�Zee�Gd
d�de��ZGdd
�d
e�ZGdd�de�ZdS)z"
Tests for L{twisted.test.iosim}.
�)�absolute_import�division)�implementer)�
IPushProducer)�Protocol)�
FakeTransport�connect)�TestCasec@s(eZdZdZdd�Zdd�Zdd�ZdS)	�FakeTransportTestsz%
    Tests for L{FakeTransport}.
    cCsHtt�d�}tt�d�}|�|jt�|�|jt�|�|j|j�dS)ze
        Each L{FakeTransport} receives a serial number that uniquely identifies
        it.
        TFN)r�objectZassertIsInstance�serial�intZassertNotEqual)�self�a�b�r�9/usr/lib/python3/dist-packages/twisted/test/test_iosim.py�test_connectionSerials
z(FakeTransportTests.test_connectionSerialcCs>tt�d�}|�d�|�dddg�|�d�|j�d�dS)	zl
        L{FakeTransport.writeSequence} will write a sequence of L{bytes} to the
        transport.
        F�a�b�c�d�sabcdN)rr�writeZ
writeSequence�assertEqual�join�stream�rrrrr�test_writeSequence$s
z%FakeTransportTests.test_writeSequencecCs@tt�d�}|�d�|��|�d�|�d�|j�d�dS)z�
        L{FakeTransport.write} will accept writes after transport was closed,
        but the data will be silently discarded.
        FsbeforesafterrN)rrrZloseConnectionrrrrrrr�test_writeAfterClose1s


z'FakeTransportTests.test_writeAfterCloseN)�__name__�
__module__�__qualname__�__doc__rrrrrrrr
s
r
c@s,eZdZdZdZdd�Zdd�Zdd�Zd	S)
�StrictPushProducerz�
    An L{IPushProducer} implementation which produces nothing but enforces
    preconditions on its state transition methods.
    �runningcCs|jdkrtd��d|_dS)N�stoppedz)Cannot stop already-stopped IPushProducer)�_state�
ValueError�rrrr�
stopProducingGs
z StrictPushProducer.stopProducingcCs$|jdkrtd�|j���d|_dS)Nr%zCannot pause {} IPushProducer�paused�r'r(�formatr)rrr�pauseProducingMs


�z!StrictPushProducer.pauseProducingcCs$|jdkrtd�|j���d|_dS)Nr+zCannot resume {} IPushProducerr%r,r)rrr�resumeProducingUs


�z"StrictPushProducer.resumeProducingN)r r!r"r#r'r*r.r/rrrrr$?s
r$c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(S))�StrictPushProducerTestsz*
    Tests for L{StrictPushProducer}.
    cCst�S)zp
        @return: A new L{StrictPushProducer} which has not been through any state
            changes.
        )r$r)rrr�_initialbsz StrictPushProducerTests._initialcCst�}|��|S)z@
        @return: A new, stopped L{StrictPushProducer}.
        )r$r*�r�producerrrr�_stoppedjsz StrictPushProducerTests._stoppedcCst�}|��|S)z?
        @return: A new, paused L{StrictPushProducer}.
        )r$r.r2rrr�_pausedsszStrictPushProducerTests._pausedcCst�}|��|��|S)zY
        @return: A new L{StrictPushProducer} which has been paused and resumed.
        )r$r.r/r2rrr�_resumed|sz StrictPushProducerTests._resumedcCs|�|jd�dS)z�
        Assert that the given producer is in the stopped state.

        @param producer: The producer to verify.
        @type producer: L{StrictPushProducer}
        r&N�rr'r2rrr�
assertStopped�sz%StrictPushProducerTests.assertStoppedcCs|�|jd�dS)z�
        Assert that the given producer is in the paused state.

        @param producer: The producer to verify.
        @type producer: L{StrictPushProducer}
        r+Nr7r2rrr�assertPaused�sz$StrictPushProducerTests.assertPausedcCs|�|jd�dS)z�
        Assert that the given producer is in the running state.

        @param producer: The producer to verify.
        @type producer: L{StrictPushProducer}
        r%Nr7r2rrr�
assertRunning�sz%StrictPushProducerTests.assertRunningcCs|�t|��j�dS)zz
        L{StrictPushProducer.stopProducing} raises L{ValueError} if called when
        the producer is stopped.
        N)�assertRaisesr(r4r*r)rrr�test_stopThenStop�sz)StrictPushProducerTests.test_stopThenStopcCs|�t|��j�dS)z{
        L{StrictPushProducer.pauseProducing} raises L{ValueError} if called when
        the producer is stopped.
        N)r;r(r4r.r)rrr�test_stopThenPause�sz*StrictPushProducerTests.test_stopThenPausecCs|�t|��j�dS)z|
        L{StrictPushProducer.resumeProducing} raises L{ValueError} if called when
        the producer is stopped.
        N)r;r(r4r/r)rrr�test_stopThenResume�sz+StrictPushProducerTests.test_stopThenResumecCs|��}|��|�|�dS)zn
        L{StrictPushProducer} is stopped if C{stopProducing} is called on a paused
        producer.
        N)r5r*r8r2rrr�test_pauseThenStop�sz*StrictPushProducerTests.test_pauseThenStopcCs|��}|�t|j�dS)zs
        L{StrictPushProducer.pauseProducing} raises L{ValueError} if called on a
        paused producer.
        N)r5r;r(r.r2rrr�test_pauseThenPause�sz+StrictPushProducerTests.test_pauseThenPausecCs|��}|��|�|�dS)zp
        L{StrictPushProducer} is resumed if C{resumeProducing} is called on a
        paused producer.
        N)r5r/r:r2rrr�test_pauseThenResume�sz,StrictPushProducerTests.test_pauseThenResumecCs|��}|��|�|�dS)zo
        L{StrictPushProducer} is stopped if C{stopProducing} is called on a
        resumed producer.
        N)r6r*r8r2rrr�test_resumeThenStop�sz+StrictPushProducerTests.test_resumeThenStopcCs|��}|��|�|�dS)zo
        L{StrictPushProducer} is paused if C{pauseProducing} is called on a
        resumed producer.
        N)r6r.r9r2rrr�test_resumeThenPause�sz,StrictPushProducerTests.test_resumeThenPausecCs|��}|�t|j�dS)zu
        L{StrictPushProducer.resumeProducing} raises L{ValueError} if called on a
        resumed producer.
        N)r6r;r(r/r2rrr�test_resumeThenResume�sz-StrictPushProducerTests.test_resumeThenResumecCs|��}|��|�|�dS)zn
        L{StrictPushProducer} is stopped if C{stopProducing} is called in the
        initial state.
        N)r1r*r8r2rrr�	test_stop�sz!StrictPushProducerTests.test_stopcCs|��}|��|�|�dS)zn
        L{StrictPushProducer} is paused if C{pauseProducing} is called in the
        initial state.
        N)r1r.r9r2rrr�
test_pausesz"StrictPushProducerTests.test_pausecCs|��}|�t|j�dS)zz
        L{StrictPushProducer} raises L{ValueError} if C{resumeProducing} is called
        in the initial state.
        N)r1r;r(r/r2rrr�test_resume
sz#StrictPushProducerTests.test_resumeN)r r!r"r#r1r4r5r6r8r9r:r<r=r>r?r@rArBrCrDrErFrGrrrrr0^s(		




	


	

r0c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�IOPumpTestsz
    Tests for L{IOPump}.
    c	Csrt�}t|dd�}t�}t|dd�}t||||dd�}t�}||d�|}|j|dd�|��|�d|j�dS)	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)ZisServerF)Zgreet)�server�client)Z	streamingr%N)rrrr$ZregisterProducer�pumprr')	r�modeZserverProtoZserverTransportZclientProtoZclientTransportrKr3Zvictimrrr�_testStreamingProducers(���z"IOPumpTests._testStreamingProducercCs|jdd�dS)z�
        L{IOPump.pump} does not call C{resumeProducing} on a L{IPushProducer}
        (stream producer) registered with the server transport.
        rI�rLN�rMr)rrr�test_serverStreamingProducer:sz(IOPumpTests.test_serverStreamingProducercCs|jdd�dS)z�
        L{IOPump.pump} does not call C{resumeProducing} on a L{IPushProducer}
        (stream producer) registered with the client transport.
        rJrNNrOr)rrr�test_clientStreamingProducerBsz(IOPumpTests.test_clientStreamingProducerN)r r!r"r#rMrPrQrrrrrHs"rHN)r#Z
__future__rrZzope.interfacerZtwisted.internet.interfacesrZtwisted.internet.protocolrZtwisted.test.iosimrrZtwisted.trial.unittestr	r
rr$r0rHrrrr�<module>s,7