o
    ¯bô§  ã                   @   sJ  d Z ddlZddlZddlmZ ddlmZmZmZ ddl	m
Z
 ddlmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ G dd„ dejƒZG dd„ dejƒZG dd„ dejƒZ G dd„ dej!ƒZ"G dd„ dejƒZ#G dd„ dej!ƒZ$G dd„ dej!ƒZ%G dd„ dƒZ&G dd„ de&ej'ƒZ(G d d!„ d!ƒZ)G d"d#„ d#ej!e)ƒZ*G d$d%„ d%e)ƒZ+G d&d'„ d'ƒZ,G d(d)„ d)e&ej-ƒZ.G d*d+„ d+ej!e+e,ƒZ/G d,d-„ d-e&ej0ƒZ1G d.d/„ d/ej!e+e,ƒZ2G d0d1„ d1e&ej3ƒZ4G d2d3„ d3ej!e+e,ƒZ5G d4d5„ d5ƒZ6G d6d7„ d7ejƒZ7G d8d9„ d9ej!ƒZ8G d:d;„ d;ej9ƒZ:dS )<z,
Test cases for L{twisted.protocols.basic}.
é    N)ÚBytesIO)ÚListÚOptionalÚType)ÚverifyObject)ÚprotocolÚtask)Ú	IProducer)ÚconnectionDone)Úbasic)Ú	iterbytes)ÚFailure)Úproto_helpers)Úunittestc                   @   ó,   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	S )
ÚFlippingLineTesterzT
    A line receiver that flips between line and raw data modes after one byte.
    ó   
c                 C   ó
   g | _ d S ©N)Úlines©Úself© r   úC/usr/lib/python3/dist-packages/twisted/protocols/test/test_basic.pyÚ__init__!   ó   
zFlippingLineTester.__init__c                 C   s   | j  |¡ |  ¡  dS )z&
        Set the mode to raw.
        N)r   ÚappendÚ
setRawMode©r   Úliner   r   r   ÚlineReceived$   s   zFlippingLineTester.lineReceivedc                 C   s   |   |dd… ¡ dS )z,
        Set the mode back to line.
        é   N)ÚsetLineMode©r   Údatar   r   r   ÚrawDataReceived+   s   z"FlippingLineTester.rawDataReceivedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	delimiterr   r    r%   r   r   r   r   r      s    r   c                   @   sB   e Zd ZdZdZdZddd„Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dS )Ú
LineTestera×  
    A line receiver that parses data received and make actions on some tokens.

    @type delimiter: C{bytes}
    @ivar delimiter: character used between received lines.
    @type MAX_LENGTH: C{int}
    @ivar MAX_LENGTH: size of a line when C{lineLengthExceeded} will be called.
    @type clock: L{twisted.internet.task.Clock}
    @ivar clock: clock simulating reactor callLater. Pass it to constructor if
        you want to use the pause/rawpause functionalities.
    r   é@   Nc                 C   s
   || _ dS )z@
        If given, use a clock to make callLater calls.
        N)Úclock)r   r-   r   r   r   r   B   ó   
zLineTester.__init__c                 C   ó
   g | _ dS ©z;
        Create/clean data received on connection.
        N©Úreceivedr   r   r   r   ÚconnectionMadeH   r.   zLineTester.connectionMadec                 C   sî   | j  |¡ |dkr|  ¡  dS |dkr"|  ¡  | j d| j¡ dS |dkr>|  ¡  |  ¡  | j  d¡ | j d| j¡ dS |dkrH|  ¡  dS |dd… dkr[t|dd… ƒ| _	dS | 
d	¡ri| j | d
¡ dS | 
d¡ru| j ¡  dS dS )z|
        Receive line and make some action for some tokens: pause, rawpause,
        stop, len, produce, unproduce.
        ó    ó   pauser   ó   rawpauseó   stopNé   s   len ó   produceFó	   unproduce)r2   r   r   ÚpauseProducingr-   Ú	callLaterÚresumeProducingÚstopProducingÚintÚlengthÚ
startswithÚ	transportÚregisterProducerÚunregisterProducerr   r   r   r   r    N   s(   

ÿzLineTester.lineReceivedc                 C   s^   |d| j … || j d… }}| j t|ƒ | _ | jd | | jd< | j dkr-|  |¡ dS dS )zj
        Read raw data, until the quantity specified by a previous 'len' line is
        reached.
        Néÿÿÿÿr   )r@   Úlenr2   r"   )r   r$   Úrestr   r   r   r%   g   s   
ÿzLineTester.rawDataReceivedc                 C   s2   t |ƒ| jd kr|  || jd d… ¡ dS dS )z<
        Adjust line mode when long lines received.
        r!   N)rF   Ú
MAX_LENGTHr"   r   r   r   r   ÚlineLengthExceededr   s   ÿzLineTester.lineLengthExceededr   )r&   r'   r(   r)   r*   rH   r   r3   r    r%   rI   r   r   r   r   r+   2   s    
r+   c                   @   s(   e Zd ZdZdZdZdd„ Zdd„ ZdS )	ÚLineOnlyTesterz)
    A buffering line only receiver.
    r   r,   c                 C   r/   r0   r1   r   r   r   r   r3   ‚   r.   zLineOnlyTester.connectionMadec                 C   ó   | j  |¡ dS )z%
        Save received data.
        N©r2   r   r   r   r   r   r    ˆ   ó   zLineOnlyTester.lineReceivedN)r&   r'   r(   r)   r*   rH   r3   r    r   r   r   r   rJ   z   s    rJ   c                   @   sº   e Zd ZdZdZg d¢Zdd„ ZdZg d¢Zedg Z	d	d
„ Z
dZg d¢Zg d¢Zdd„ ZdZg d¢Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&S )'ÚLineReceiverTestsz\
    Test L{twisted.protocols.basic.LineReceiver}, using the C{LineTester}
    wrapper.
    sž   len 10

0123456789len 5

1234
len 20
foo 123

0123456789
012345678len 0
foo 5

1234567890123456789012345678901234567890123456789012345678901234567890
len 1

a)s   len 10ó
   0123456789ó   len 5s   1234
s   len 20s   foo 123s   0123456789
012345678s   len 0s   foo 5r4   s   67890s   len 1ó   ac                 C   ó‚   t ddƒD ]9}t ¡ }tƒ }| t |¡¡ t t| jƒ| d ƒD ]}| j|| |d | … }| 	|¡ q!|  
| j|j¡ qdS )zl
        Test buffering for different packet size, checking received matches
        expected data.
        r!   é
   N)Úranger   ÚStringIOWithoutClosingr+   ÚmakeConnectionr   ÚFileWrapperrF   ÚbufferÚdataReceivedÚassertEqualÚoutputr2   ©r   Úpacket_sizeÚtÚaÚiÚsr   r   r   Útest_buffer·   s   ùzLineReceiverTests.test_buffers!   twiddle1
twiddle2
pause
twiddle3
)ó   twiddle1ó   twiddle2r5   ó   twiddle3c                 C   ó¦   t ddƒD ]K}t ¡ }t ¡ }t|ƒ}| t |¡¡ t t	| j
ƒ| d ƒD ]}| j
|| |d | … }| |¡ q&|  | j|j¡ | d¡ |  | j|j¡ qdS )zo
        Test pause inside data receiving. It uses fake clock to see if
        pausing/resuming work.
        r!   rS   r   N)rT   r   rU   r   ÚClockr+   rV   r   rW   rF   ÚpauseBufrY   rZ   ÚpauseOutput1r2   ÚadvanceÚpauseOutput2©r   r]   r^   r-   r_   r`   ra   r   r   r   Útest_pausingÊ   s   
özLineReceiverTests.test_pausings/   twiddle1
twiddle2
len 5
rawpause
12345twiddle3
)rc   rd   rP   r6   r4   )rc   rd   rP   r6   s   12345re   c                 C   rf   )z7
        Test pause inside raw date receiving.
        r!   rS   r   N)rT   r   rU   r   rg   r+   rV   r   rW   rF   ÚrawpauseBufrY   rZ   ÚrawpauseOutput1r2   rj   ÚrawpauseOutput2rl   r   r   r   Útest_rawPausingç   s   
öz!LineReceiverTests.test_rawPausings"   twiddle1
twiddle2
stop
more
stuff
)rc   rd   r7   c                 C   rR   )z-
        Test stop inside producing.
        r!   rS   N)rT   r   rU   r+   rV   r   rW   rF   Ústop_bufrY   rZ   Ústop_outputr2   r\   r   r   r   Útest_stopProducingû   s   ùz$LineReceiverTests.test_stopProducingc                 C   s>   t ƒ }t ¡ }| t |¡¡ | d¡ |  |jg d¢¡ dS )z6
        Test produce/unproduce in receiving.
        s&   produce
hello world
unproduce
goodbye
)r9   s   hello worldr:   ó   goodbyeN)	r+   r   rU   rV   r   rW   rY   rZ   r2   )r   r_   r^   r   r   r   Útest_lineReceiverAsProducer  s   

ÿz-LineReceiverTests.test_lineReceiverAsProducerc                 C   sh   G dd„ dt jƒ}|ƒ }| d¡ |  |jd¡ |  |jd¡ | d¡ |  |jd¡ |  |jd¡ d	S )
z 
        L{LineReceiver.clearLineBuffer} removes all buffered data and returns
        it as a C{bytes} and can be called from beneath C{dataReceived}.
        c                   @   ó   e Zd Zdd„ ZdS )z@LineReceiverTests.test_clearLineBuffer.<locals>.ClearingReceiverc                 S   s   || _ |  ¡ | _d S r   )r   ÚclearLineBufferrG   r   r   r   r   r      s   zMLineReceiverTests.test_clearLineBuffer.<locals>.ClearingReceiver.lineReceivedN)r&   r'   r(   r    r   r   r   r   ÚClearingReceiver  ó    ry   s   foo
bar
bazó   foos   bar
bazs   quux
s   quuxr4   N)r   ÚLineReceiverrY   rZ   r   rG   )r   ry   r   r   r   r   Útest_clearLineBuffer  s   

z&LineReceiverTests.test_clearLineBufferc                 C   sP   t ƒ }t ¡ }| t |¡¡ t ¡ }| d| ¡ |  	d| d 
|j¡¡ dS )zC
        Test switching modes many times on the same data.
        s   x
xó   xr4   N)r   r   rU   rV   r   rW   ÚsysÚgetrecursionlimitrY   rZ   Újoinr   )r   ÚprotorB   Úlimitr   r   r   Útest_stackRecursion*  s   z%LineReceiverTests.test_stackRecursionc                 C   óB   t  ¡ }t ¡ }| |¡ | d|jd  d ¡ |  |j¡ dS ©zx
        C{LineReceiver} disconnects the transport if it receives a line longer
        than its C{MAX_LENGTH}.
        r~   r!   ó   
rN©	r   r|   r   ÚStringTransportrV   rY   rH   Ú
assertTrueÚdisconnecting©r   r‚   rB   r   r   r   Útest_maximumLineLength5  ó
   
z(LineReceiverTests.test_maximumLineLengthc                 C   s–   t ƒ }d|_t ¡ }| |¡ d|jd  }| |¡ | |jdd… ¡ | |jdd… | ¡ |  |j¡ |  	t
|jƒd¡ |  	||jd ¡ dS )a~  
        C{LineReceiver} doesn't disconnect the transport when it
        receives a finished line as long as its C{MAX_LENGTH}, when
        the second-to-last packet ended with a pattern that could have
        been -- and turns out to have been -- the start of a
        delimiter, and that packet causes the total input to exceed
        C{MAX_LENGTH} + len(delimiter).
        r8   r~   r!   NrE   r   )r+   rH   r   r‰   rV   rY   r*   ÚassertFalser‹   rZ   rF   r2   )r   r‚   r^   r   r   r   r   Ú&test_maximumLineLengthPartialDelimiter@  s   	

z8LineReceiverTests.test_maximumLineLengthPartialDelimiterc                 C   sX   t  ¡ }d|_t ¡ }| |¡ | d|j |jdt|jƒd …  ¡ |  	|j
¡ dS )aO  
        C{LineReceiver} doesn't disconnect the transport it if
        receives a non-finished line whose length, counting the
        delimiter, is longer than its C{MAX_LENGTH} but shorter than
        its C{MAX_LENGTH} + len(delimiter). (When the first part that
        exceeds the max is the beginning of the delimiter.)
        s   
r~   Nr!   )r   r|   r*   r   r‰   rV   rY   rH   rF   r   r‹   rŒ   r   r   r   Ú(test_notQuiteMaximumLineLengthUnfinishedV  s   
 ÿz:LineReceiverTests.test_notQuiteMaximumLineLengthUnfinishedc                 C   sF   t  ¡ }dd„ |_t ¡ }| |¡ | ¡  | d¡}|  |t	¡ dS )zf
        C{LineReceiver.dataReceived} forwards errors returned by
        C{rawDataReceived}.
        c                 S   s   t dƒS )NÚoops)ÚRuntimeError©r$   r   r   r   Ú<lambda>o  s    z5LineReceiverTests.test_rawDataError.<locals>.<lambda>s   dataN)
r   r|   r%   r   r‰   rV   r   rY   ÚassertIsInstancer“   )r   r‚   rB   Úwhyr   r   r   Útest_rawDataErrori  s   


z#LineReceiverTests.test_rawDataErrorc                 C   ó   t  ¡ }|  t|jd¡ dS )z‰
        When L{LineReceiver.rawDataReceived} is not overridden in a
        subclass, calling it raises C{NotImplementedError}.
        ÚfooN)r   r|   ÚassertRaisesÚNotImplementedErrorr%   ©r   r‚   r   r   r   Ú"test_rawDataReceivedNotImplementedv  ó   z4LineReceiverTests.test_rawDataReceivedNotImplementedc                 C   r™   )z†
        When L{LineReceiver.lineReceived} is not overridden in a subclass,
        calling it raises C{NotImplementedError}.
        rš   N)r   r|   r›   rœ   r    r   r   r   r   Útest_lineReceivedNotImplemented~  rŸ   z1LineReceiverTests.test_lineReceivedNotImplementedN)r&   r'   r(   r)   rX   r[   rb   rh   ri   rk   rm   rn   ro   rp   rq   rr   rs   rt   rv   r}   r„   r   r   r‘   r˜   rž   r    r   r   r   r   rN      s2    
	rN   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚExcessivelyLargeLineCatcherz®
    Helper for L{LineReceiverLineLengthExceededTests}.

    @ivar longLines: A L{list} of L{bytes} giving the values
        C{lineLengthExceeded} has been called with.
    c                 C   r   r   )Ú	longLinesr   r   r   r   r3     r   z*ExcessivelyLargeLineCatcher.connectionMadec                 C   s   dS )z/
        Disregard any received lines.
        Nr   r   r   r   r   r    ’  s    z(ExcessivelyLargeLineCatcher.lineReceivedc                 C   rK   )zF
        Record any data that exceeds the line length limits.
        N)r¢   r   r#   r   r   r   rI   —  rM   z.ExcessivelyLargeLineCatcher.lineLengthExceededN)r&   r'   r(   r)   r3   r    rI   r   r   r   r   r¡   ‡  s
    r¡   c                   @   sH   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dS )Ú#LineReceiverLineLengthExceededTestszO
    Tests for L{twisted.protocols.basic.LineReceiver.lineLengthExceeded}.
    c                 C   s,   t ƒ | _d| j_t ¡ | _| j | j¡ d S )Né   )r¡   r‚   rH   r   r‰   rB   rV   r   r   r   r   ÚsetUp£  s   
z)LineReceiverLineLengthExceededTests.setUpc                 C   s6   d| j jd d  }| j  |¡ |  |g| j j¡ dS )zÊ
        If more bytes than C{LineReceiver.MAX_LENGTH} arrive containing no line
        delimiter, all of the bytes are passed as a single string to
        L{LineReceiver.lineLengthExceeded}.
        r~   é   N)r‚   rH   rY   rZ   r¢   ©r   Ú	excessiver   r   r   Útest_longUnendedLine©  s   z8LineReceiverLineLengthExceededTests.test_longUnendedLinec                 C   sB   d| j jd d  }| j  d| j j | ¡ |  |g| j j¡ dS )a*  
        If L{LineReceiver.dataReceived} is called with bytes representing a
        short line followed by bytes that exceed the length limit without a
        line delimiter, L{LineReceiver.lineLengthExceeded} is called with all
        of the bytes following the short line's delimiter.
        r~   r¦   N)r‚   rH   rY   r*   rZ   r¢   r§   r   r   r   Útest_longLineAfterShortLine³  s   z?LineReceiverLineLengthExceededTests.test_longLineAfterShortLinec                 C   sF   | j j d| j jd d  gd ¡}| j  |¡ |  |g| j j¡ dS )a  
        If L{LineReceiver.dataReceived} is called with more than
        C{LineReceiver.MAX_LENGTH} bytes containing a line delimiter somewhere
        not in the first C{MAX_LENGTH} bytes, the entire byte string is passed
        to L{LineReceiver.lineLengthExceeded}.
        r~   r¦   N)r‚   r*   r   rH   rY   rZ   r¢   r§   r   r   r   Útest_longLineWithDelimiter¾  s
   ÿz>LineReceiverLineLengthExceededTests.test_longLineWithDelimiterc                 C   sB   d| j jd d  | j j d }| j  |¡ |  |g| j j¡ dS )a  
        If L{LineReceiver.dataReceived} is called with more than
        C{LineReceiver.MAX_LENGTH} bytes containing multiple line delimiters
        somewhere not in the first C{MAX_LENGTH} bytes, the entire byte string
        is passed to L{LineReceiver.lineLengthExceeded}.
        r~   r¦   N)r‚   rH   r*   rY   rZ   r¢   r§   r   r   r   Útest_multipleLongLinesË  s    z:LineReceiverLineLengthExceededTests.test_multipleLongLinesc                 C   r…   r†   rˆ   rŒ   r   r   r   r   Ö  rŽ   z:LineReceiverLineLengthExceededTests.test_maximumLineLengthc                 C   sD   t  ¡ }t ¡ }| |¡ | d|jt|jƒ  ¡ |  	|j
¡ dS )z…
        C{LineReceiver} disconnects the transport it if receives a non-finished
        line longer than its C{MAX_LENGTH}.
        r~   N)r   r|   r   r‰   rV   rY   rH   rF   r*   rŠ   r‹   rŒ   r   r   r   Útest_maximumLineLengthRemainingá  s
   
zCLineReceiverLineLengthExceededTests.test_maximumLineLengthRemainingN)r&   r'   r(   r)   r¥   r©   rª   r«   r¬   r   r­   r   r   r   r   r£   ž  s    
r£   c                   @   r   )
ÚLineOnlyReceiverTestsz@
    Tests for L{twisted.protocols.basic.LineOnlyReceiver}.
    s7   foo
    bleakness
    desolation
    plastic forks
    c                 C   sT   t  ¡ }tƒ }| |¡ t| jƒD ]}| |¡ q|  |j| j 	d¡dd… ¡ dS )zW
        Test buffering over line protocol: data received should match buffer.
        r   NrE   )
r   r‰   rJ   rV   r   rX   rY   rZ   r2   Úsplit)r   r^   r_   Úcr   r   r   rb   ø  s   
"z!LineOnlyReceiverTests.test_bufferc                 C   sJ   t ƒ }t ¡ }| |¡ | d|jt|jƒ d  d ¡ |  |j	¡ dS )z
        C{LineOnlyReceiver} disconnects the transport if it receives a
        line longer than its C{MAX_LENGTH} + len(delimiter).
        r~   r!   r‡   N)
rJ   r   r‰   rV   rY   rH   rF   r*   rŠ   r‹   rŒ   r   r   r   Ú!test_greaterThanMaximumLineLength  s   
ÿz7LineOnlyReceiverTests.test_greaterThanMaximumLineLengthc                 C   r™   )zŠ
        When L{LineOnlyReceiver.lineReceived} is not overridden in a subclass,
        calling it raises C{NotImplementedError}.
        rš   N)r   ÚLineOnlyReceiverr›   rœ   r    r   r   r   r   r      rŸ   z5LineOnlyReceiverTests.test_lineReceivedNotImplementedN)r&   r'   r(   r)   rX   rb   r±   r    r   r   r   r   r®   í  s    r®   c                   @   s:   e Zd Zdd„ Zdd„ ZdZdZefdedd	fd
d„Z	d	S )Ú	TestMixinc                 C   r   r   r1   r   r   r   r   r3     r   zTestMixin.connectionMadec                 C   ó   | j  |¡ d S r   rL   ©r   ra   r   r   r   ÚstringReceived  ó   zTestMixin.stringReceivedé2   r   ÚreasonÚreturnNc                 C   ó
   d| _ d S )Nr!   )Úclosed)r   r¹   r   r   r   ÚconnectionLost#  r   zTestMixin.connectionLost)
r&   r'   r(   r3   r¶   rH   r¼   r
   r   r½   r   r   r   r   r³     s    r³   c                   @   rw   )ÚTestNetstringc                 C   s   | j  |¡ | j |¡ d S r   )r2   r   rB   Úwriterµ   r   r   r   r¶   (  s   zTestNetstring.stringReceivedN)r&   r'   r(   r¶   r   r   r   r   r¾   '  rz   r¾   c                   @   s>   e Zd ZU g Zeee  ed< dZded< dd„ Z	dd„ Z
dS )	ÚLPTestCaseMixinÚillegalStringsNú!Optional[Type[protocol.Protocol]]r   c                 C   s   t  ¡ }|  ¡ }| |¡ |S )z„
        Return a new instance of C{self.protocol} connected to a new instance
        of L{proto_helpers.StringTransport}.
        )r   r‰   r   rV   )r   r^   r_   r   r   r   ÚgetProtocol2  s   
zLPTestCaseMixin.getProtocolc                 C   s>   | j D ]}|  ¡ }t|ƒD ]}| |¡ q|  |jj¡ qdS )zO
        Assert that illegal strings cause the transport to be closed.
        N)rÁ   rÃ   r   rY   rŠ   rB   r‹   ©r   ra   Úrr°   r   r   r   Útest_illegal<  ó   
üzLPTestCaseMixin.test_illegal)r&   r'   r(   rÁ   r   r   ÚbytesÚ__annotations__r   rÃ   rÆ   r   r   r   r   rÀ   -  s
   
 
rÀ   c                   @   sÔ   e Zd ZdZg d¢Zg d¢ZeZdd„ Zdd„ Z	dd	„ Z
d
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0S )1ÚNetstringReceiverTestszA
    Tests for L{twisted.protocols.basic.NetstringReceiver}.
    )ó   helloó   worlds   hows   ares   you123s   :todays  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)s   9999999999999999999999s   abcs   4:abcdes7   51:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab,c                 C   s$   t  ¡ | _tƒ | _| j | j¡ d S r   )r   r‰   rB   r¾   ÚnetstringReceiverrV   r   r   r   r   r¥   W  s   
zNetstringReceiverTests.setUpc                 C   s    t ddƒD ]H}t ¡ }tƒ }d|_| |¡ | jD ]}| |¡ q| ¡ }t t	|ƒ| d ƒD ]}||| |d | … }|rD| 
|¡ q/|  |j| j¡ qdS )zI
        Strings can be received in chunks of different lengths.
        r!   rS   i»  N)rT   r   r‰   r¾   rH   rV   ÚstringsÚ
sendStringÚvaluerF   rY   rZ   r2   )r   r]   r^   r_   ra   Úoutr`   r   r   r   rb   \  s   


€ôz"NetstringReceiverTests.test_bufferc                 C   ó"   | j  d¡ |  | j jdg¡ dS )zE
        Empty netstrings (with length '0') can be received.
        s   0:,r4   N©rÍ   rY   rZ   r2   r   r   r   r   Útest_receiveEmptyNetstringn  ó   z1NetstringReceiverTests.test_receiveEmptyNetstringc                 C   rÒ   )z;
        One-character netstrings can be received.
        ó   1:a,rQ   NrÓ   r   r   r   r   Útest_receiveOneCharacteru  rÕ   z/NetstringReceiverTests.test_receiveOneCharacterc                 C   rÒ   )z;
        Two-character netstrings can be received.
        s   2:ab,ó   abNrÓ   r   r   r   r   Útest_receiveTwoCharacters|  rÕ   z0NetstringReceiverTests.test_receiveTwoCharactersc                 C   rÒ   )zÙ
        Netstrings with embedded netstrings. This test makes sure that
        the parser does not become confused about the ',' and ':'
        characters appearing inside the data portion of the netstring.
        s   4:1:a,,rÖ   NrÓ   r   r   r   r   Útest_receiveNestedNetstringƒ  s   z2NetstringReceiverTests.test_receiveNestedNetstringc                 C   ó   | j  d¡ |  | jj¡ dS )zL
        Netstrings containing more data than expected are refused.
        s   2:aaa,N©rÍ   rY   rŠ   rB   r‹   r   r   r   r   Útest_moreDataThanSpecifiedŒ  ó   z1NetstringReceiverTests.test_moreDataThanSpecifiedc                 C   rÛ   )zƒ
        Netstrings that should be empty according to their length
        specification are refused if they contain data.
        s   0:a,NrÜ   r   r   r   r   Ú$test_moreDataThanSpecifiedBorderCase“  ó   z;NetstringReceiverTests.test_moreDataThanSpecifiedBorderCasec                 C   rÛ   )z`
        Netstrings without leading digits that specify the length
        are refused.
        s   :aaa,NrÜ   r   r   r   r   Útest_missingNumber›  rà   z)NetstringReceiverTests.test_missingNumberc                 C   rÛ   )zg
        Netstrings without a colon between length specification and
        data are refused.
        s   3aaa,NrÜ   r   r   r   r   Útest_missingColon£  rà   z(NetstringReceiverTests.test_missingColonc                 C   rÛ   )zY
        Netstrings that have no leading digits nor a colon are
        refused.
        s   aaa,NrÜ   r   r   r   r   Útest_missingNumberAndColon«  rà   z1NetstringReceiverTests.test_missingNumberAndColonc                 C   rÛ   )zA
        Netstrings consisting only of data are refused.
        s   aaaNrÜ   r   r   r   r   Útest_onlyData³  rÞ   z$NetstringReceiverTests.test_onlyDatac                 C   s>   | j  d¡ | j  d¡ |  | j jdg¡ |  | j  ¡ ¡ dS )z=
        Netstrings can be received in two portions.
        s   4:aas   aa,s   aaaaN)rÍ   rY   rZ   r2   rŠ   Ú_payloadCompleter   r   r   r   Útest_receiveNetstringPortions_1º  s   z6NetstringReceiverTests.test_receiveNetstringPortions_1c                 C   ó,   dD ]}| j  |¡ q|  | j jdg¡ dS )zŽ
        Netstrings can be received in more than two portions, even if
        the length specification is split across two portions.
        )ó   1s   0:01234s   56789ó   ,rO   NrÓ   ©r   Úpartr   r   r   Útest_receiveNetstringPortions_2Ã  s   z6NetstringReceiverTests.test_receiveNetstringPortions_2c                 C   rç   )zE
        Netstrings can be received one character at a time.
        )ó   2ó   :rQ   ó   bré   rØ   NrÓ   rê   r   r   r   Útest_receiveNetstringPortions_3Ì  s   z6NetstringReceiverTests.test_receiveNetstringPortions_3c                 C   sR   | j  d¡ |  | j  ¡ ¡ |  | j jdg¡ | j  d¡ |  | j jddg¡ dS )zÑ
        A stream of two netstrings can be received in two portions,
        where the first portion contains the complete first netstring
        and the length specification of the second netstring.
        s   1:a,1rQ   s   :b,rï   N)rÍ   rY   rŠ   rå   rZ   r2   r   r   r   r   Útest_receiveTwoNetstringsÔ  s
   z0NetstringReceiverTests.test_receiveTwoNetstringsc                 C   s>   | j jd }| j  d t|ƒdd| f¡¡ |  | jj¡ dS )zs
        Netstrings with a length specification exceeding the specified
        C{MAX_LENGTH} are refused.
        r!   r4   rî   rQ   N)rÍ   rH   rY   r   rÈ   rŠ   rB   r‹   )r   ÚtooLongr   r   r   Útest_maxReceiveLimità  s
   ÿz+NetstringReceiverTests.test_maxReceiveLimitc                 C   s&   d| j _| j  ¡  |  | j jd¡ dS )zw
        C{_consumeLength} returns the expected length of the
        netstring, including the trailing comma.
        ó   12:é   N)rÍ   Ú_remainingDataÚ_consumeLengthrZ   Ú_expectedPayloadSizer   r   r   r   Útest_consumeLengthë  s   
z)NetstringReceiverTests.test_consumeLengthc                 C   s.   d| j _d| j _| j  ¡  |  | j jd¡ dS )zŒ
        C{_consumeLength} works as expected if the length specification
        contains the value of C{MAX_LENGTH} (border case).
        rô   é   rõ   N)rÍ   rö   rH   r÷   rZ   rø   r   r   r   r   Útest_consumeLengthBorderCase1ô  s   
z4NetstringReceiverTests.test_consumeLengthBorderCase1c                 C   ó&   d| j _d| j _|  tj| j j¡ dS )z¬
        C{_consumeLength} raises a L{basic.NetstringParseError} if
        the length specification exceeds the value of C{MAX_LENGTH}
        by 1 (border case).
        rô   é   N©rÍ   rö   rH   r›   r   ÚNetstringParseErrorr÷   r   r   r   r   Útest_consumeLengthBorderCase2þ  ó
   
ÿz4NetstringReceiverTests.test_consumeLengthBorderCase2c                 C   rü   )z¨
        C{_consumeLength} raises a L{basic.NetstringParseError} if
        the length specification exceeds the value of C{MAX_LENGTH}
        by more than 1.
        s   1000:rý   Nrþ   r   r   r   r   Útest_consumeLengthBorderCase3
  r  z4NetstringReceiverTests.test_consumeLengthBorderCase3c                 C   r™   )z
        When L{NetstringReceiver.stringReceived} is not overridden in a
        subclass, calling it raises C{NotImplementedError}.
        rš   N)r   ÚNetstringReceiverr›   rœ   r¶   r   r   r   r   Ú!test_stringReceivedNotImplemented  rŸ   z8NetstringReceiverTests.test_stringReceivedNotImplementedN)r&   r'   r(   r)   rÎ   rÁ   r¾   r   r¥   rb   rÔ   r×   rÙ   rÚ   rÝ   rß   rá   râ   rã   rä   ræ   rì   rð   rñ   ró   rù   rû   r   r  r  r   r   r   r   rÊ   G  s6    				
rÊ   c                   @   sŠ   e Zd ZU dZdZded< dZeee	  ed< dZ
eee	  ed< dZeee	  ed< dd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚIntNTestCaseMixinz4
    TestCase mixin for int-prefixed protocols.
    NrÂ   r   rÎ   rÁ   ÚpartialStringsc                 C   sR   |   ¡ }| jD ]}tt |jt|ƒ¡| ƒD ]}| |¡ qq|  |j	| j¡ dS )z>
        Test receiving data find the same data send.
        N)
rÃ   rÎ   r   ÚstructÚpackÚstructFormatrF   rY   rZ   r2   )r   rÅ   ra   r°   r   r   r   Útest_receive)  s   
ÿzIntNTestCaseMixin.test_receivec                 C   s>   | j D ]}|  ¡ }t|ƒD ]}| |¡ q|  |jg ¡ qdS )zK
        Send partial data, nothing should be definitely received.
        N)r  rÃ   r   rY   rZ   r2   rÄ   r   r   r   Útest_partial3  rÇ   zIntNTestCaseMixin.test_partialc                 C   s6   |   ¡ }| d¡ |  |j ¡ t |jd¡d ¡ dS )z2
        Test sending data over protocol.
        ó   bbbbbbbbbbbbbbbbé   N)rÃ   rÏ   rZ   rB   rÐ   r  r  r	  ©r   rÅ   r   r   r   Ú	test_send=  s
   
ÿzIntNTestCaseMixin.test_sendc                 C   s@   g }|   ¡ }|j|_d|_| t |jd¡¡ |  |dg¡ dS )zÍ
        When a length prefix is received which is greater than the protocol's
        C{MAX_LENGTH} attribute, the C{lengthLimitExceeded} method is called
        with the received length prefix.
        rS   rý   N)	rÃ   r   ÚlengthLimitExceededrH   rY   r  r  r	  rZ   )r   r@   rÅ   r   r   r   Útest_lengthLimitExceededG  s   z*IntNTestCaseMixin.test_lengthLimitExceededc                 C   s8   |   ¡ }d|_| t |jd¡d ¡ |  |jg ¡ dS )zÑ
        If a length prefix for a string longer than C{MAX_LENGTH} is delivered
        to C{dataReceived} at the same time as the entire string, the string is
        not passed to C{stringReceived}.
        rS   rý   s   xxxxxxxxxxxN)rÃ   rH   rY   r  r  r	  rZ   r2   r  r   r   r   Útest_longStringNotDeliveredT  s   z-IntNTestCaseMixin.test_longStringNotDeliveredc                 C   r™   )zŽ
        When L{IntNStringReceiver.stringReceived} is not overridden in a
        subclass, calling it raises C{NotImplementedError}.
        rš   N)r   ÚIntNStringReceiverr›   rœ   r¶   r   r   r   r   r  _  rŸ   z3IntNTestCaseMixin.test_stringReceivedNotImplemented)r&   r'   r(   r)   r   rÉ   rÎ   r   r   rÈ   rÁ   r  r
  r  r  r  r  r  r   r   r   r   r    s   
 


r  c                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚRecvdAttributeMixinzÐ
    Mixin defining tests for string receiving protocols with a C{recvd}
    attribute which should be settable by application code, to be combined with
    L{IntNTestCaseMixin} on a L{TestCase} subclass
    c                 C   s   t  |jt|ƒ¡| S )zg
        Return C{data} prefixed with message length in C{protocol.structFormat}
        form.
        )r  r  r	  rF   )r   r   r$   r   r   r   ÚmakeMessageo  s   zRecvdAttributeMixin.makeMessagec                    sd   g ‰|   ¡ ‰ ‡ ‡fdd„}|ˆ _t ˆ jd¡d }t ˆ jd¡d }ˆ  || ¡ |  ˆ|g¡ dS )z˜
        In stringReceived, recvd contains the remaining data that was passed to
        dataReceived that was not part of the current message.
        c                    s   ˆ  ˆ j¡ d S r   ©r   Úrecvd©ÚreceivedString©rÅ   Úresultr   r   r¶   ~  r·   zKRecvdAttributeMixin.test_recvdContainsRemainingData.<locals>.stringReceivedé   ó   aaaaas   bbbbN)rÃ   r¶   r  r  r	  rY   rZ   )r   r¶   ÚcompleteMessageÚincompleteMessager   r  r   Útest_recvdContainsRemainingDatav  s   z3RecvdAttributeMixin.test_recvdContainsRemainingDatac                    st   |   ¡ ‰g ‰d}|  ˆ|¡‰ ‡ ‡‡fdd„}|ˆ_d}d}|  ˆ|¡}|  ˆ|¡}ˆ || ¡ |  ˆ||g¡ dS )zŠ
        In stringReceived, if recvd is changed, messages should be parsed from
        it rather than the input to dataReceived.
        s   cccccc                    s   ˆsˆ ˆ_ ˆ | ¡ d S r   )r  r   r  ©ÚmessageCrÅ   r  r   r   r¶   ’  s   z=RecvdAttributeMixin.test_recvdChanged.<locals>.stringReceivedr  s   bbbbbN)rÃ   r  r¶   rY   rZ   )r   ÚpayloadCr¶   ÚpayloadAÚpayloadBÚmessageAÚmessageBr   r!  r   Útest_recvdChangedˆ  s   z%RecvdAttributeMixin.test_recvdChangedc                    sŒ   |   ¡ ‰g }d‰ | jD ]}| |  ˆ|¡¡ | ˆ ¡ qg ‰‡ ‡‡fdd„}|ˆ_ˆ d |¡¡ ˆ d¡ |  ˆ| j¡ |  ˆjd¡ dS )z¹
        Data already parsed by L{IntNStringReceiver.dataReceived} is not
        reparsed if C{stringReceived} consumes some of the
        L{IntNStringReceiver.recvd} buffer.
        s       c                    s"   ˆ  | ¡ ˆjtˆ ƒd … ˆ_d S r   )r   r  rF   r  ©ÚSWITCHr‚   r  r   r   r¶   ®  s   
z:RecvdAttributeMixin.test_switching.<locals>.stringReceivedr4   ó   N)	rÃ   rÎ   r   r  r¶   rY   r   rZ   r  )r   Úmixra   r¶   r   r)  r   Útest_switchingŸ  s   

z"RecvdAttributeMixin.test_switchingc                    sp   |   ¡ ‰ d}t|ƒd ˆ _|  ˆ |¡}g ‰‡ ‡fdd„}|ˆ _ˆ  |¡ |  ˆd t|ƒ¡ |  ˆd |¡ dS )z¾
        The L{IntNStringReceiver.recvd} buffer contains all data not yet
        processed by L{IntNStringReceiver.dataReceived} if the
        C{lengthLimitExceeded} event occurs.
        s   too longr!   c                    s   ˆ  | ¡ ˆ  ˆ j¡ d S r   r  )r@   ©r‚   r  r   r   r  È  s   
zPRecvdAttributeMixin.test_recvdInLengthLimitExceeded.<locals>.lengthLimitExceededr   N)rÃ   rF   rH   r  r  rY   rZ   )r   ÚDATAÚmessager  r   r.  r   Útest_recvdInLengthLimitExceeded»  s   
z3RecvdAttributeMixin.test_recvdInLengthLimitExceededN)	r&   r'   r(   r)   r  r   r(  r-  r1  r   r   r   r   r  h  s    r  c                   @   ó   e Zd ZdZdS )Ú	TestInt32zƒ
    A L{basic.Int32StringReceiver} storing received strings in an array.

    @ivar received: array holding received strings.
    N©r&   r'   r(   r)   r   r   r   r   r3  Ò  ó    r3  c                   @   s2   e Zd ZdZeZddgZdgZg d¢Zdd„ Z	dS )	Ú
Int32Testsz/
    Test case for int32-prefixed protocol
    rQ   r  s
      aaaaaa)s      ó   hello therer4   c                 C   óB   |   ¡ }| d¡ |  |j ¡ d¡ | d¡ |  |jdg¡ dS )z?
        Test specific behavior of the 32-bits length.
        r{   s      foos      ubaró   ubarN©rÃ   rÏ   rZ   rB   rÐ   rY   r2   r  r   r   r   Ú	test_dataä  ó
   

zInt32Tests.test_dataN)
r&   r'   r(   r)   r3  r   rÎ   rÁ   r  r;  r   r   r   r   r6  Ú  s    r6  c                   @   r2  )Ú	TestInt16zƒ
    A L{basic.Int16StringReceiver} storing received strings in an array.

    @ivar received: array holding received strings.
    Nr4  r   r   r   r   r=  ï  r5  r=  c                   @   ó:   e Zd ZdZeZddgZdgZg d¢Zdd„ Z	dd	„ Z
d
S )Ú
Int16Testsz/
    Test case for int16-prefixed protocol
    rQ   r  s    aaaaaa)ó    r7  r4   c                 C   r8  )z?
        Test specific behavior of the 16-bits length.
        r{   s    foos    ubarr9  Nr:  r  r   r   r   r;    r<  zInt16Tests.test_datac                 C   ó2   |   ¡ }dd|jd  d  }|  t|j|¡ dS ©zA
        Send too much data: that should cause an error.
        rï   r¦   é   r!   N©rÃ   ÚprefixLengthr›   ÚAssertionErrorrÏ   ©r   rÅ   ÚtooSendr   r   r   Útest_tooLongSend  ó   zInt16Tests.test_tooLongSendN)r&   r'   r(   r)   r=  r   rÎ   rÁ   r  r;  rI  r   r   r   r   r?  ÷  ó    
r?  c                   @   r2  )ÚTestInt8z‚
    A L{basic.Int8StringReceiver} storing received strings in an array.

    @ivar received: array holding received strings.
    Nr4  r   r   r   r   rL    r5  rL  c                   @   r>  )Ú	Int8Testsz.
    Test case for int8-prefixed protocol
    rQ   r  s     aaaaaa)ó   s   dzadzr4   c                 C   r8  )z>
        Test specific behavior of the 8-bits length.
        r{   s   foos   ubarr9  Nr:  r  r   r   r   r;  &  r<  zInt8Tests.test_datac                 C   rA  rB  rD  rG  r   r   r   rI  0  rJ  zInt8Tests.test_tooLongSendN)r&   r'   r(   r)   rL  r   rÎ   rÁ   r  r;  rI  r   r   r   r   rM    rK  rM  c                   @   s8   e Zd ZdZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Z	dS )ÚOnlyProducerTransportzm
    Transport which isn't really a transport, just looks like one to
    someone not looking very hard.
    Fc                 C   r   r   r”   r   r   r   r   r   B  r   zOnlyProducerTransport.__init__c                 C   r»   )NT©Úpausedr   r   r   r   r;   E  r   z$OnlyProducerTransport.pauseProducingc                 C   r»   )NFrP  r   r   r   r   r=   H  r   z%OnlyProducerTransport.resumeProducingc                 C   r´   r   )r$   r   )r   rÈ   r   r   r   r¿   K  r·   zOnlyProducerTransport.writeN)
r&   r'   r(   r)   rQ  r‹   r   r;   r=   r¿   r   r   r   r   rO  9  s    rO  c                   @   ó   e Zd ZdZdd„ ZdS )ÚConsumingProtocolzC
    Protocol that really, really doesn't want any more bytes.
    c                 C   s   | j  |¡ |  ¡  d S r   )rB   r¿   r;   r   r   r   r   r    T  s   zConsumingProtocol.lineReceivedN)r&   r'   r(   r)   r    r   r   r   r   rS  O  ó    rS  c                   @   rR  )ÚProducerTestszM
    Tests for L{basic._PausableMixin} and L{basic.LineReceiver.paused}.
    c                 C   sª  t ƒ }tƒ }| |¡ | d¡ |  |jg ¡ |  |j¡ |  |j¡ | d¡ |  |jdg¡ |  |j¡ |  |j¡ | 	¡  |  |jdg¡ |  |j¡ |  |j¡ | d¡ |  |jddg¡ |  |j¡ |  |j¡ | 	¡  |  |jg d¢¡ |  |j¡ |  |j¡ | d¡ |  |jg d¢¡ |  |j¡ |  |j¡ | 	¡  |  |jg d¢¡ |  |j¡ |  |j¡ | 	¡  |  |jg d¢¡ |  |j¡ |  |j¡ d	S )
a?  
        When L{basic.LineReceiver} is paused, it doesn't deliver lines to
        L{basic.LineReceiver.lineReceived} and delivers them immediately upon
        being resumed.

        L{ConsumingProtocol} is a L{LineReceiver} that pauses itself after
        every line, and writes that line to its transport.
        s   hello, s   world
ó   hello, worlds   hello
world
rË   )rV  rË   rÌ   s	   goodbye
)rV  rË   rÌ   ru   N)
rS  rO  rV   rY   rZ   r$   r   rQ  rŠ   r=   )r   Úpr^   r   r   r   Útest_pauseResume^  sF   	




zProducerTests.test_pauseResumeN)r&   r'   r(   r)   rX  r   r   r   r   rU  Y  rT  rU  c                   @   s@   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )ÚFileSenderTestsz(
    Tests for L{basic.FileSender}.
    c                 C   s   t  ¡ }|  tt|ƒ¡ dS )zP
        L{basic.FileSender} implements the L{IPullProducer} interface.
        N)r   Ú
FileSenderrŠ   r   r	   )r   Úsenderr   r   r   Útest_interface§  s   zFileSenderTests.test_interfacec                 C   sB   t dƒ}t ¡ }t ¡ }| ||¡ |  |j|¡ |  |j	¡ dS )z˜
        When L{basic.FileSender.beginFileTransfer} is called, it registers
        itself with provided consumer, as a non-streaming producer.
        ó   Test contentN)
r   r   r‰   r   rZ  ÚbeginFileTransferrZ   Úproducerr   Ú	streaming)r   ÚsourceÚconsumerr[  r   r   r   Útest_producerRegistered®  s   z'FileSenderTests.test_producerRegisteredc                 C   sf   t dƒ}t ¡ }t ¡ }| ||¡}| ¡  | ¡  |  |j¡ |  	d|  
|¡¡ |  	d| ¡ ¡ dS )zÐ
        L{basic.FileSender} sends the content of the given file using a
        C{IConsumer} interface via C{beginFileTransfer}. It returns a
        L{Deferred} which fires with the last byte sent.
        r]  ó   tN)r   r   r‰   r   rZ  r^  r=   ÚassertIsNoner_  rZ   ÚsuccessResultOfrÐ   ©r   ra  rb  r[  Údr   r   r   Útest_transferº  s   zFileSenderTests.test_transferc                 C   s    t dƒ}t ¡ }t ¡ }d|_| ||¡}| ¡  |  d| 	¡ ¡ | ¡  |  d| 	¡ ¡ | ¡  |  d| 	¡ ¡ | ¡  |  d|  
|¡¡ |  d| 	¡ ¡ dS )zj
        L{basic.FileSender} reads at most C{CHUNK_SIZE} every time it resumes
        producing.
        r]  r8   s   Tests   Test conrd  N)r   r   r‰   r   rZ  Ú
CHUNK_SIZEr^  r=   rZ   rÐ   rf  rg  r   r   r   Útest_transferMultipleChunksÌ  s   z+FileSenderTests.test_transferMultipleChunksc                 C   sd   dd„ }t dƒ}t ¡ }t ¡ }| |||¡}| ¡  | ¡  |  d|  |¡¡ |  d| 	¡ ¡ dS )z
        L{basic.FileSender.beginFileTransfer} takes a C{transform} argument
        which allows to manipulate the data on the fly.
        c                 S   s   |   ¡ S r   )Úswapcase)Úchunkr   r   r   Ú	transformé  s   z=FileSenderTests.test_transferWithTransform.<locals>.transformr]  ó   Ts   tEST CONTENTN)
r   r   r‰   r   rZ  r^  r=   rZ   rf  rÐ   )r   rn  ra  rb  r[  rh  r   r   r   Útest_transferWithTransformã  s   z*FileSenderTests.test_transferWithTransformc                 C   sV   t dƒ}t ¡ }t ¡ }| ||¡}| ¡  |  |¡}| t	¡ |  
dt|jƒ¡ dS )zµ
        The C{Deferred} returned by L{basic.FileSender.beginFileTransfer} fails
        with an C{Exception} if C{stopProducing} when the transfer is not
        complete.
        r]  z#Consumer asked us to stop producingN)r   r   r‰   r   rZ  r^  r>   ÚfailureResultOfÚtrapÚ	ExceptionrZ   ÚstrrÐ   )r   ra  rb  r[  rh  Úfailurer   r   r   Útest_abortedTransfer÷  s   

z$FileSenderTests.test_abortedTransferN)
r&   r'   r(   r)   r\  rc  ri  rk  rp  rv  r   r   r   r   rY  ¢  s    rY  );r)   r  r   Úior   Útypingr   r   r   Úzope.interface.verifyr   Útwisted.internetr   r   Útwisted.internet.interfacesr	   Útwisted.internet.protocolr
   Útwisted.protocolsr   Útwisted.python.compatr   Útwisted.python.failurer   Útwisted.testr   Útwisted.trialr   r|   r   r+   r²   rJ   ÚSynchronousTestCaserN   r¡   r£   r®   r³   r  r¾   rÀ   rÊ   r  r  ÚInt32StringReceiverr3  r6  ÚInt16StringReceiverr=  r?  ÚInt8StringReceiverrL  rM  rO  rS  rU  ÚTestCaserY  r   r   r   r   Ú<module>   sN   H yO, YIj
I