
    h                         S r SSKJrJrJr  SSKJr  SSKJr  SSK	J
r
   " S S\5      r " S S	\5      r " S
 S\
\R                  5      rg)z+
Test cases for twisted.protocols.stateful
    )calcsizepackunpack)StatefulProtocol)
test_basic)TestCasec                   T    \ rS rSrSrSrSr\" \5      rS r	S r
S rS rS	 rS
 rSrg)MyInt32StringReceiver   z!
A stateful Int32StringReceiver.
i z!Ic                     U R                   S4$ N   )
_getHeaderselfs    a/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/test/test_stateful.pygetInitialState%MyInt32StringReceiver.getInitialState   s    !!    c                 8    U R                   R                  5         g N)	transportloseConnection)r   lengths     r   lengthLimitExceeded)MyInt32StringReceiver.lengthLimitExceeded   s    %%'r   c                 |    [        SU5      u  nX R                  :  a  U R                  U5        g U R                  U4$ )N!i)r   
MAX_LENGTHr   
_getString)r   msgr   s      r   r    MyInt32StringReceiver._getHeader   s:    4%	OO#$$V,&&r   c                 @    U R                  U5        U R                  S4$ r   )stringReceivedr   r   r!   s     r   r     MyInt32StringReceiver._getString&   s    C !!r   c                     [         e)z
Override this.
)NotImplementedErrorr%   s     r   r$   $MyInt32StringReceiver.stringReceived*   s
     "!r   c                 z    U R                   R                  [        U R                  [	        U5      5      U-   5        g)zC
Send an int32-prefixed string to the other end of the connection.
N)r   writer   structFormatlen)r   datas     r   
sendString MyInt32StringReceiver.sendString0   s,     	T$"3"3SY?$FGr    N)__name__
__module____qualname____firstlineno____doc__r   r,   r   prefixLengthr   r   r   r    r$   r/   __static_attributes__r1   r   r   r
   r
      s<     JLL)L"('""Hr   r
   c                   .    \ rS rSrS rS rSrSrS rSr	g)		TestInt327   c                     / U l         g r   )receivedr   s    r   connectionMadeTestInt32.connectionMade8   s	    r   c                 :    U R                   R                  U5        g r   )r=   append)r   ss     r   r$   TestInt32.stringReceived;   s    Qr   2   r   c                     SU l         g )N   )closed)r   reasons     r   connectionLostTestInt32.connectionLostA   s	    r   )rG   r=   N)
r2   r3   r4   r5   r>   r$   r   rG   rI   r8   r1   r   r   r:   r:   7   s      JFr   r:   c                   4    \ rS rSr\rSS/rS/r/ SQrS r	Sr
g)	
Int32TestsE      as   bbbbbbbbbbbbbbbbs
      aaaaaa)s      s   hello therer   c                     U R                  5       nSnU R                  S-   H  nU[        S[        U5      5      U-   -  nM      UR	                  U5        U R                  UR                  U R                  S-  5        g )Nr   r   r   )getProtocolstringsr   r-   dataReceivedassertEqualr=   )r   rbigrB   s       r   test_bigReceiveInt32Tests.test_bigReceiveK   sk    !A4c!f%))C "	sT\\A%56r   r1   N)r2   r3   r4   r5   r:   protocolrQ   illegalStringspartialStringsrV   r8   r1   r   r   rL   rL   E   s#    HYG/0N;N7r   rL   N)r6   structr   r   r   twisted.protocols.statefulr   twisted.protocols.testr   twisted.trial.unittestr   r
   r:   IntNTestCaseMixinrL   r1   r   r   <module>r`      sL   
 * ) 7 - +$H, $HN% 7:77 7r   