HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/twisted/test/__pycache__/test_stateful.cpython-310.pyc
o

�b��@stdZddlmZmZmZddlmZddlmZddl	m
Z
Gdd�de�ZGdd	�d	e�ZGd
d�de
ej
�ZdS)
z+
Test cases for twisted.protocols.stateful
�)�calcsize�pack�unpack)�StatefulProtocol)�
test_basic)�TestCasec@sPeZdZdZdZdZee�Zdd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dS)�MyInt32StringReceiverz)
    A stateful Int32StringReceiver.
    i��z!IcCs
|jdfS�N�)�
_getHeader��self�r�</usr/lib/python3/dist-packages/twisted/test/test_stateful.py�getInitialState�
z%MyInt32StringReceiver.getInitialStatecCs|j��dS�N)�	transport�loseConnection)r
�lengthrrr�lengthLimitExceededsz)MyInt32StringReceiver.lengthLimitExceededcCs.td|�\}||jkr|�|�dS|j|fS)N�!i)r�
MAX_LENGTHr�
_getString)r
�msgrrrrrs



z MyInt32StringReceiver._getHeadercCs|�|�|jdfSr	)�stringReceivedr�r
rrrrr&s

z MyInt32StringReceiver._getStringcCst�)z 
        Override this.
        )�NotImplementedErrorrrrrr*sz$MyInt32StringReceiver.stringReceivedcCs |j�t|jt|��|�dS)zS
        Send an int32-prefixed string to the other end of the connection.
        N)r�writer�structFormat�len)r
�datarrr�
sendString0s z MyInt32StringReceiver.sendStringN)�__name__�
__module__�__qualname__�__doc__rrr�prefixLengthrrrrrr"rrrrrsrc@s,eZdZdd�Zdd�ZdZdZdd�Zd	S)
�	TestInt32cCs
g|_dSr)�receivedrrrr�connectionMade8rzTestInt32.connectionMadecCs|j�|�dSr)r)�append)r
�srrrr;szTestInt32.stringReceived�2rcCs
d|_dS)N�)�closed)r
�reasonrrr�connectionLostArzTestInt32.connectionLostN)r#r$r%r*rrr/r1rrrrr(7sr(c@s.eZdZeZddgZdgZgd�Zdd�ZdS)�
Int32Tests�asbbbbbbbbbbbbbbbbs
aaaaaa)sshello there�cCsT|��}d}|jdD]
}|tdt|��|7}q|�|�|�|j|jd�dS)Nr4r
r)�getProtocol�stringsrr �dataReceived�assertEqualr))r
�r�bigr,rrr�test_bigReceiveKs
zInt32Tests.test_bigReceiveN)	r#r$r%r(�protocolr6�illegalStrings�partialStringsr;rrrrr2Esr2N)r&�structrrr�twisted.protocols.statefulr�twisted.protocols.testr�twisted.trial.unittestrrr(�IntNTestCaseMixinr2rrrr�<module>s'