
    Vh                        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ej8                        Z G d dej8                        Z G d dej>                        Z  G d dejB                        Z" G d dej8                        Z# G d dejB                        Z$ G d dejB                        Z% G d d      Z& G d de&ejN                        Z( G d  d!      Z) G d" d#ejB                  e)      Z* G d$ d%e)      Z+ G d& d'      Z, G d( d)e&ejZ                        Z. G d* d+ejB                  e+e,      Z/ G d, d-e&ej`                        Z1 G d. d/ejB                  e+e,      Z2 G d0 d1e&ejf                        Z4 G d2 d3ejB                  e+e,      Z5 G d4 d5      Z6 G d6 d7ej8                        Z7 G d8 d9ejB                        Z8 G d: d;ejr                        Z:y)<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 Zd Zd Zy)FlippingLineTesterzT
    A line receiver that flips between line and raw data modes after one byte.
       
c                     g | _         y N)linesselfs    Q/home/dcms/DCMS/lib/python3.12/site-packages/twisted/protocols/test/test_basic.py__init__zFlippingLineTester.__init__!   s	    
    c                 Z    | j                   j                  |       | j                          y)z&
        Set the mode to raw.
        N)r   append
setRawModer   lines     r   lineReceivedzFlippingLineTester.lineReceived$   s      	

$r   c                 ,    | j                  |dd        y)z,
        Set the mode back to line.
           N)setLineModer   datas     r   rawDataReceivedz"FlippingLineTester.rawDataReceived+   s     	ab"r   N)__name__
__module____qualname____doc__	delimiterr   r!   r'    r   r   r   r      s     I#r   r   c                   8    e Zd ZdZdZdZd
dZd Zd Zd Z	d	 Z
y)
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                     || _         y)z@
        If given, use a clock to make callLater calls.
        N)clock)r   r2   s     r   r   zLineTester.__init__B   s     
r   c                     g | _         yz;
        Create/clean data received on connection.
        Nreceivedr   s    r   connectionMadezLineTester.connectionMadeH        r   c                    | j                   j                  |       |dk(  r| j                          y|dk(  r7| j                          | j                  j                  d| j                         y|dk(  rb| j                          | j                          | j                   j                  d       | j                  j                  d| j                         y|dk(  r| j                          y|dd dk(  rt        |dd       | _	        y|j                  d	      r| j                  j                  | d
       y|j                  d      r| j                  j                          yy)z|
        Receive line and make some action for some tokens: pause, rawpause,
        stop, len, produce, unproduce.
        r      pauser      rawpause   stopN   s   len    produceF	   unproduce)r6   r   r   pauseProducingr2   	callLaterresumeProducingstopProducingintlength
startswith	transportregisterProducerunregisterProducerr   s     r   r!   zLineTester.lineReceivedN   s   
 	T"3;OOX!JJ  D$8$89[ !OOMM  %JJ  D$8$89W_ "1X d12h-DK__Z(NN++D%8__\*NN--/ +r   c                     |d| j                    || j                   d }}| j                   t        |      z
  | _         | j                  d   |z   | j                  d<   | j                   dk(  r| j                  |       yy)zj
        Read raw data, until the quantity specified by a previous 'len' line is
        reached.
        Nr   )rE   lenr6   r$   )r   r&   rests      r   r'   zLineTester.rawDataReceivedg   sr    
 -DKK($t{{}*=dkkCI- MM"-4b;;!T" r   c                 ~    t        |      | j                  dz   kD  r"| j                  || j                  dz   d        yy)z<
        Adjust line mode when long lines received.
        r#   N)rL   
MAX_LENGTHr$   r   s     r   lineLengthExceededzLineTester.lineLengthExceededr   s=     t9t**T$//A"5"789 +r   r   )r(   r)   r*   r+   r,   rO   r   r7   r!   r'   rP   r-   r   r   r/   r/   2   s,    
 IJ02	#:r   r/   c                   $    e Zd ZdZdZdZd Zd Zy)LineOnlyTesterz)
    A buffering line only receiver.
    r   r0   c                     g | _         yr4   r5   r   s    r   r7   zLineOnlyTester.connectionMade   r8   r   c                 :    | j                   j                  |       y)z%
        Save received data.
        Nr6   r   r   s     r   r!   zLineOnlyTester.lineReceived   s     	T"r   N)r(   r)   r*   r+   r,   rO   r7   r!   r-   r   r   rR   rR   z   s     IJ#r   rR   c                       e Zd ZdZdZg dZd ZdZg dZedgz   Z	d Z
d	Zg d
Zg dZd ZdZg dZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)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 5r   s   67890s   len 1   ac                    t        dd      D ]  }t        j                         }t               }|j	                  t        j                  |             t        t        | j                        |z  dz         D ]+  }| j                  ||z  |dz   |z   }|j                  |       - | j                  | j                  |j                          y)zl
        Test buffering for different packet size, checking received matches
        expected data.
        r#   
   N)ranger   StringIOWithoutClosingr/   makeConnectionr   FileWrapperrL   bufferdataReceivedassertEqualoutputr6   r   packet_sizetaiss         r   test_bufferzLineReceiverTests.test_buffer   s    
 !B< 	6K446AAX11!453t{{+{:Q>? "KKK1q5K2GHq!" T[[!**5	6r   s!   twiddle1
twiddle2
pause
twiddle3
)   twiddle1   twiddle2r:      twiddle3c                 6   t        dd      D ]	  }t        j                         }t        j                         }t        |      }|j                  t        j                  |             t        t        | j                        |z  dz         D ]+  }| j                  ||z  |dz   |z   }|j                  |       - | j                  | j                  |j                         |j                  d       | j                  | j                   |j                          y)zo
        Test pause inside data receiving. It uses fake clock to see if
        pausing/resuming work.
        r#   r\   r   N)r]   r   r^   r	   Clockr/   r_   r   r`   rL   pauseBufrb   rc   pauseOutput1r6   advancepauseOutput2r   rf   rg   r2   rh   ri   rj   s          r   test_pausingzLineReceiverTests.test_pausing   s    
 !B< 
	<K446AJJLE5!AX11!453t}}-<q@A "MM!k/QUk4IJq!" T..

;MM!T..

;
	<r   s/   twiddle1
twiddle2
len 5
rawpause
12345twiddle3
)rl   rm   rY   r;   r   )rl   rm   rY   r;   s   12345rn   c                 6   t        dd      D ]	  }t        j                         }t        j                         }t        |      }|j                  t        j                  |             t        t        | j                        |z  dz         D ]+  }| j                  ||z  |dz   |z   }|j                  |       - | j                  | j                  |j                         |j                  d       | j                  | j                   |j                          y)z7
        Test pause inside raw date receiving.
        r#   r\   r   N)r]   r   r^   r	   rp   r/   r_   r   r`   rL   rawpauseBufrb   rc   rawpauseOutput1r6   rs   rawpauseOutput2ru   s          r   test_rawPausingz!LineReceiverTests.test_rawPausing   s     !B< 
	?K446AJJLE5!AX11!453t//0K?!CD "$$Q_A7LMq!" T111::>MM!T111::>
	?r   s"   twiddle1
twiddle2
stop
more
stuff
)rl   rm   r<   c                    t        dd      D ]  }t        j                         }t               }|j	                  t        j                  |             t        t        | j                        |z  dz         D ]+  }| j                  ||z  |dz   |z   }|j                  |       - | j                  | j                  |j                          y)z-
        Test stop inside producing.
        r#   r\   N)r]   r   r^   r/   r_   r   r`   rL   stop_bufrb   rc   stop_outputr6   re   s         r   test_stopProducingz$LineReceiverTests.test_stopProducing   s     !B< 	;K446AAX11!453t}}-<q@A "MM!k/QUk4IJq!" T--qzz:	;r   c                     t               }t        j                         }|j                  t	        j
                  |             |j                  d       | j                  |j                  g d       y)z6
        Test produce/unproduce in receiving.
        s&   produce
hello world
unproduce
goodbye
)r>   s   hello worldr?      goodbyeN)	r/   r   r^   r_   r   r`   rb   rc   r6   )r   rh   rg   s      r   test_lineReceiverAsProducerz-LineReceiverTests.test_lineReceiverAsProducer  sW     L002	--a01	DEJJN	
r   c                 l    G d dt         j                        } |       } |j                  d       | j                  |j                  d       | j                  |j
                  d        |j                  d       | j                  |j                  d       | j                  |j
                  d       y	)
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 Zy)@LineReceiverTests.test_clearLineBuffer.<locals>.ClearingReceiverc                 <    || _         | j                         | _        y r   )r    clearLineBufferrM   r   s     r   r!   zMLineReceiverTests.test_clearLineBuffer.<locals>.ClearingReceiver.lineReceived  s     	 002	r   N)r(   r)   r*   r!   r-   r   r   ClearingReceiverr     s    3r   r   s   foo
bar
baz   foos   bar
bazs   quux
s   quuxr   N)r   LineReceiverrb   rc   r    rM   )r   r   r   s      r   test_clearLineBufferz&LineReceiverTests.test_clearLineBuffer  s    	3u11 	3
 $%23/6 	k*0,r   c                 4   t               }t        j                         }|j                  t	        j
                  |             t        j                         }|j                  d|z         | j                  d|z  dj                  |j                               y)zC
        Test switching modes many times on the same data.
        s   x
x   xr   N)r   r   r^   r_   r   r`   sysgetrecursionlimitrb   rc   joinr   )r   protorG   limits       r   test_stackRecursionz%LineReceiverTests.test_stackRecursion*  st     #$!88:	X11)<=%%'7U?+sxx'<=r   c                     t        j                         }t        j                         }|j	                  |       |j                  d|j                  dz   z  dz          | j                  |j                         yzx
        C{LineReceiver} disconnects the transport if it receives a line longer
        than its C{MAX_LENGTH}.
        r   r#      
rN	r   r   r   StringTransportr_   rb   rO   
assertTruedisconnectingr   r   rG   s      r   test_maximumLineLengthz(LineReceiverTests.test_maximumLineLength5  c    
 ""$!113	Y'45#3#3a#788CD	//0r   c                    t               }d|_        t        j                         }|j	                  |       d|j                  dz
  z  }|j                  |       |j                  |j                  dd        |j                  |j                  dd |z          | j                  |j                         | j                  t        |j                        d       | j                  ||j                  d          y)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).
        r=   r   r#   NrK   r   )r/   rO   r   r   r_   rb   r,   assertFalser   rc   rL   r6   )r   r   rg   r    s       r   &test_maximumLineLengthPartialDelimiterz8LineReceiverTests.test_maximumLineLengthPartialDelimiter@  s     ))+Qu''!+,4 5??3B/05??23/$67)U^^,a0u~~a01r   c                 B   t        j                         }d|_        t        j                         }|j                  |       |j                  d|j                  z  |j                  dt        |j                        dz
   z          | j                  |j                         y)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   r_   rb   rO   rL   r   r   r   s      r   (test_notQuiteMaximumLineLengthUnfinishedz:LineReceiverTests.test_notQuiteMaximumLineLengthUnfinishedV  s     ""$ "!113	Y'E$$$8R#eoo:NQR:R(SS	
 	001r   c                     t        j                         }d |_        t        j                         }|j                  |       |j                          |j                  d      }| j                  |t               y)zf
        C{LineReceiver.dataReceived} forwards errors returned by
        C{rawDataReceived}.
        c                     t        d      S )Noops)RuntimeErrorr&   s    r   <lambda>z5LineReceiverTests.test_rawDataError.<locals>.<lambda>o  s    \&-A r   s   dataN)
r   r   r'   r   r   r_   r   rb   assertIsInstancer   )r   r   rG   whys       r   test_rawDataErrorz#LineReceiverTests.test_rawDataErrori  sb    
 ""$ A!113	Y'  )c<0r   c                 n    t        j                         }| j                  t        |j                  d       y)z
        When L{LineReceiver.rawDataReceived} is not overridden in a
        subclass, calling it raises C{NotImplementedError}.
        fooN)r   r   assertRaisesNotImplementedErrorr'   r   r   s     r   "test_rawDataReceivedNotImplementedz4LineReceiverTests.test_rawDataReceivedNotImplementedv  s+    
 ""$-u/D/DeLr   c                 n    t        j                         }| j                  t        |j                  d       y)z
        When L{LineReceiver.lineReceived} is not overridden in a subclass,
        calling it raises C{NotImplementedError}.
        r   N)r   r   r   r   r!   r   s     r   test_lineReceivedNotImplementedz1LineReceiverTests.test_lineReceivedNotImplemented~  s+    
 ""$-u/A/A5Ir   N)r(   r)   r*   r+   ra   rd   rk   rq   rr   rt   rv   rx   ry   rz   r{   r}   r~   r   r   r   r   r   r   r   r   r   r   r-   r   r   rW   rW      s    
F$F 6 8H7L;-/L<" JKLOO?  :H5K;

-,	>	12,2&1MJr   rW   c                   "    e Zd ZdZd Zd Zd Zy)ExcessivelyLargeLineCatcherz
    Helper for L{LineReceiverLineLengthExceededTests}.

    @ivar longLines: A L{list} of L{bytes} giving the values
        C{lineLengthExceeded} has been called with.
    c                     g | _         y r   )	longLinesr   s    r   r7   z*ExcessivelyLargeLineCatcher.connectionMade  s	    r   c                      y)z/
        Disregard any received lines.
        Nr-   r   s     r   r!   z(ExcessivelyLargeLineCatcher.lineReceived  s    r   c                 :    | j                   j                  |       y)zF
        Record any data that exceeds the line length limits.
        N)r   r   r%   s     r   rP   z.ExcessivelyLargeLineCatcher.lineLengthExceeded  s     	d#r   N)r(   r)   r*   r+   r7   r!   rP   r-   r   r   r   r     s    
$r   r   c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
#LineReceiverLineLengthExceededTestszO
    Tests for L{twisted.protocols.basic.LineReceiver.lineLengthExceeded}.
    c                     t               | _        d| j                  _        t        j                         | _        | j                  j                  | j
                         y )N   )r   r   rO   r   r   rG   r_   r   s    r   setUpz)LineReceiverLineLengthExceededTests.setUp  s>    02
 !

&668

!!$..1r   c                     d| j                   j                  dz  dz   z  }| j                   j                  |       | j                  |g| j                   j                         y)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   rO   rb   rc   r   r   	excessives     r   test_longUnendedLinez8LineReceiverLineLengthExceededTests.test_longUnendedLine  sP     DJJ11A59:	

	*)djj&:&:;r   c                     d| j                   j                  dz  dz   z  }| j                   j                  d| j                   j                  z   |z          | j	                  |g| j                   j
                         y)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   rO   rb   r,   rc   r   r   s     r   test_longLineAfterShortLinez?LineReceiverLineLengthExceededTests.test_longLineAfterShortLine  sd     DJJ11A59:	

tzz';'; ;i GH)djj&:&:;r   c                    | j                   j                  j                  d| j                   j                  dz  dz   z  gdz        }| j                   j	                  |       | j                  |g| j                   j                         y)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   rO   rb   rc   r   r   s     r   test_longLineWithDelimiterz>LineReceiverLineLengthExceededTests.test_longLineWithDelimiter  sr     JJ((--TZZ**Q.234q8
	 	

	*)djj&:&:;r   c                     d| j                   j                  dz  dz   z  | j                   j                  z   dz  }| j                   j                  |       | j	                  |g| j                   j
                         y)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   rO   r,   rb   rc   r   r   s     r   test_multipleLongLinesz:LineReceiverLineLengthExceededTests.test_multipleLongLines  se     TZZ22Q6:;djj>R>RRVWW	

	*)djj&:&:;r   c                     t        j                         }t        j                         }|j	                  |       |j                  d|j                  dz   z  dz          | j                  |j                         yr   r   r   s      r   r   z:LineReceiverLineLengthExceededTests.test_maximumLineLength  r   r   c                    t        j                         }t        j                         }|j	                  |       |j                  d|j                  t        |j                        z   z         | j                  |j                         y)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   r_   rb   rO   rL   r,   r   r   r   s      r   test_maximumLineLengthRemainingzCLineReceiverLineLengthExceededTests.test_maximumLineLengthRemaining  sg    
 ""$!113	Y'45#3#3c%//6J#JKL	//0r   N)r(   r)   r*   r+   r   r   r   r   r   r   r   r-   r   r   r   r     s*    2<	<<	<	1	1r   r   c                   &    e Zd ZdZdZd Zd Zd Zy)LineOnlyReceiverTestsz@
    Tests for L{twisted.protocols.basic.LineOnlyReceiver}.
    s7   foo
    bleakness
    desolation
    plastic forks
    c                 (   t        j                         }t               }|j                  |       t	        | j
                        D ]  }|j                  |        | j                  |j                  | j
                  j                  d      dd        y)zW
        Test buffering over line protocol: data received should match buffer.
        r   NrK   )
r   r   rR   r_   r   ra   rb   rc   r6   split)r   rg   rh   cs       r   rk   z!LineOnlyReceiverTests.test_buffer  sv     ))+	4;;' 	ANN1	T[[%6%6u%=cr%BCr   c                    t               }t        j                         }|j                  |       |j	                  d|j
                  t        |j                        z   dz   z  dz          | j                  |j                         y)z
        C{LineOnlyReceiver} disconnects the transport if it receives a
        line longer than its C{MAX_LENGTH} + len(delimiter).
        r   r#   r   N)
rR   r   r   r_   rb   rO   rL   r,   r   r   r   s      r   !test_greaterThanMaximumLineLengthz7LineOnlyReceiverTests.test_greaterThanMaximumLineLength  sp    
  !113	Y'E$$s5??';;a?@8K	
 		//0r   c                 n    t        j                         }| j                  t        |j                  d       y)z
        When L{LineOnlyReceiver.lineReceived} is not overridden in a subclass,
        calling it raises C{NotImplementedError}.
        r   N)r   LineOnlyReceiverr   r   r!   r   s     r   r   z5LineOnlyReceiverTests.test_lineReceivedNotImplemented  s+    
 &&(-u/A/A5Ir   N)r(   r)   r*   r+   ra   rk   r   r   r-   r   r   r   r     s    F	D1Jr   r   c                   4    e Zd Zd Zd ZdZdZefdeddfdZ	y)		TestMixinc                     g | _         y r   r5   r   s    r   r7   zTestMixin.connectionMade  s	    r   c                 :    | j                   j                  |       y r   rU   r   rj   s     r   stringReceivedzTestMixin.stringReceived  s    Qr   2   r   reasonreturnNc                     d| _         y )Nr#   )closed)r   r   s     r   connectionLostzTestMixin.connectionLost#  s	    r   )
r(   r)   r*   r7   r   rO   r   r   r   r   r-   r   r   r   r     s.      JF/= W $ r   r   c                       e Zd Zd Zy)TestNetstringc                 p    | j                   j                  |       | j                  j                  |       y r   )r6   r   rG   writer   s     r   r   zTestNetstring.stringReceived(  s&    QQr   N)r(   r)   r*   r   r-   r   r   r   r   '  s     r   r   c                   B    e Zd ZU g Zeee      ed<   dZded<   d Z	d Z
y)LPTestCaseMixinillegalStringsN!Optional[Type[protocol.Protocol]]r   c                 p    t        j                         }| j                         }|j                  |       |S )z
        Return a new instance of C{self.protocol} connected to a new instance
        of L{proto_helpers.StringTransport}.
        )r   r   r   r_   )r   rg   rh   s      r   getProtocolzLPTestCaseMixin.getProtocol1  s0    
 ))+MMO	r   c                     | j                   D ]X  }| j                         }t        |      D ]  }|j                  |        | j	                  |j
                  j                         Z y)zO
        Assert that illegal strings cause the transport to be closed.
        N)r   r   r   rb   r   rG   r   r   rj   rr   s       r   test_illegalzLPTestCaseMixin.test_illegal;  s\     $$ 	7A  "Aq\ "q!"OOAKK556		7r   )r(   r)   r*   r   r   r   bytes__annotations__r   r   r   r-   r   r   r   r   -  s*    ,.NHT%[).48H187r   r   c                       e Zd ZdZg dZg dZeZd Zd Z	d Z
d Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)NetstringReceiverTestszA
    Tests for L{twisted.protocols.basic.NetstringReceiver}.
    )   hello   worlds   hows   ares   you123s   :todays  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)s   9999999999999999999999s   abcs   4:abcdes7   51:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab,c                     t        j                         | _        t               | _        | j                  j                  | j                         y r   )r   r   rG   r   netstringReceiverr_   r   s    r   r   zNetstringReceiverTests.setUpV  s4    &668!.--dnn=r   c                    t        dd      D ]  }t        j                         }t               }d|_        |j                  |       | j                  D ]  }|j                  |        |j                         }t        t        |      |z  dz         D ]$  }|||z  |dz   |z   }|s|j                  |       & | j                  |j                  | j                          y)zI
        Strings can be received in chunks of different lengths.
        r#   r\   i  N)r]   r   r   r   rO   r_   strings
sendStringvaluerL   rb   rc   r6   )r   rf   rg   rh   rj   outri   s          r   rk   z"NetstringReceiverTests.test_buffer[  s     !B< 	7K--/AAALQ\\  Q '')C3s8{2Q67 &K1q5K*?@NN1%& QZZ6	7r   c                     | j                   j                  d       | j                  | j                   j                  dg       y)zE
        Empty netstrings (with length '0') can be received.
        s   0:,r   Nr   rb   rc   r6   r   s    r   test_receiveEmptyNetstringz1NetstringReceiverTests.test_receiveEmptyNetstringm  s6     	++F3//883%@r   c                     | j                   j                  d       | j                  | j                   j                  dg       y)z;
        One-character netstrings can be received.
           1:a,rZ   Nr   r   s    r   test_receiveOneCharacterz/NetstringReceiverTests.test_receiveOneCharactert  s6     	++G4//884&Ar   c                     | j                   j                  d       | j                  | j                   j                  dg       y)z;
        Two-character netstrings can be received.
        s   2:ab,   abNr   r   s    r   test_receiveTwoCharactersz0NetstringReceiverTests.test_receiveTwoCharacters{  s6     	++H5//885'Br   c                     | j                   j                  d       | j                  | j                   j                  dg       y)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   s    r   test_receiveNestedNetstringz2NetstringReceiverTests.test_receiveNestedNetstring  s6     	++J7//887)Dr   c                     | j                   j                  d       | j                  | j                  j                         y)zL
        Netstrings containing more data than expected are refused.
        s   2:aaa,Nr   rb   r   rG   r   r   s    r   test_moreDataThanSpecifiedz1NetstringReceiverTests.test_moreDataThanSpecified  s.     	++I6445r   c                     | j                   j                  d       | j                  | j                  j                         y)z
        Netstrings that should be empty according to their length
        specification are refused if they contain data.
        s   0:a,Nr	  r   s    r   $test_moreDataThanSpecifiedBorderCasez;NetstringReceiverTests.test_moreDataThanSpecifiedBorderCase  .    
 	++G4445r   c                     | j                   j                  d       | j                  | j                  j                         y)z`
        Netstrings without leading digits that specify the length
        are refused.
        s   :aaa,Nr	  r   s    r   test_missingNumberz)NetstringReceiverTests.test_missingNumber  .    
 	++H5445r   c                     | j                   j                  d       | j                  | j                  j                         y)zg
        Netstrings without a colon between length specification and
        data are refused.
        s   3aaa,Nr	  r   s    r   test_missingColonz(NetstringReceiverTests.test_missingColon  r  r   c                     | j                   j                  d       | j                  | j                  j                         y)zY
        Netstrings that have no leading digits nor a colon are
        refused.
        s   aaa,Nr	  r   s    r   test_missingNumberAndColonz1NetstringReceiverTests.test_missingNumberAndColon  r  r   c                     | j                   j                  d       | j                  | j                  j                         y)zA
        Netstrings consisting only of data are refused.
        s   aaaNr	  r   s    r   test_onlyDataz$NetstringReceiverTests.test_onlyData  s.     	++F3445r   c                    | j                   j                  d       | j                   j                  d       | j                  | j                   j                  dg       | j	                  | j                   j                                y)z=
        Netstrings can be received in two portions.
        s   4:aas   aa,s   aaaaN)r   rb   rc   r6   r   _payloadCompleter   s    r   test_receiveNetstringPortions_1z6NetstringReceiverTests.test_receiveNetstringPortions_1  se     	++G4++F3//887)D..??ABr   c                     dD ]  }| j                   j                  |        | j                  | j                   j                  dg       y)z
        Netstrings can be received in more than two portions, even if
        the length specification is split across two portions.
        )   1s   0:01234s   56789   ,rX   Nr   r   parts     r   test_receiveNetstringPortions_2z6NetstringReceiverTests.test_receiveNetstringPortions_2  sE    
 7 	6D""//5	6//88=/Jr   c                     dD ]  }| j                   j                  |        | j                  | j                   j                  dg       y)zE
        Netstrings can be received one character at a time.
        )   2   :rZ      br  r  Nr   r  s     r   test_receiveNetstringPortions_3z6NetstringReceiverTests.test_receiveNetstringPortions_3  sE     3 	6D""//5	6//885'Br   c                 `   | j                   j                  d       | j                  | j                   j                                | j	                  | j                   j
                  dg       | j                   j                  d       | j	                  | j                   j
                  ddg       y)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,1rZ   s   :b,r#  N)r   rb   r   r  rc   r6   r   s    r   test_receiveTwoNetstringsz0NetstringReceiverTests.test_receiveTwoNetstrings  s     	++H5..??AB//884&A++F3//884,Gr   c                     | j                   j                  dz   }| j                   j                  dj                  t	        |      dd|z  f             | j                  | j                  j                         y)zs
        Netstrings with a length specification exceeding the specified
        C{MAX_LENGTH} are refused.
        r#   r   r"  rZ   N)r   rO   rb   r   r   r   rG   r   )r   tooLongs     r   test_maxReceiveLimitz+NetstringReceiverTests.test_maxReceiveLimit  sa    
 ((33a7++HHeGndD7N;<	
 	445r   c                     d| j                   _        | j                   j                          | j                  | j                   j                  d       y)zw
        C{_consumeLength} returns the expected length of the
        netstring, including the trailing comma.
           12:   N)r   _remainingData_consumeLengthrc   _expectedPayloadSizer   s    r   test_consumeLengthz)NetstringReceiverTests.test_consumeLength  s@    
 17---///DDbIr   c                     d| j                   _        d| j                   _        | j                   j                          | j	                  | j                   j
                  d       y)z
        C{_consumeLength} works as expected if the length specification
        contains the value of C{MAX_LENGTH} (border case).
        r+     r,  N)r   r-  rO   r.  rc   r/  r   s    r   test_consumeLengthBorderCase1z4NetstringReceiverTests.test_consumeLengthBorderCase1  sN    
 17-,.)--///DDbIr   c                     d| j                   _        d| j                   _        | j                  t        j
                  | j                   j                         y)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-  rO   r   r   NetstringParseErrorr.  r   s    r   test_consumeLengthBorderCase2z4NetstringReceiverTests.test_consumeLengthBorderCase2  sE     17-,.)%%t'='='L'L	
r   c                     d| j                   _        d| j                   _        | j                  t        j
                  | j                   j                         y)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:r5  Nr6  r   s    r   test_consumeLengthBorderCase3z4NetstringReceiverTests.test_consumeLengthBorderCase3	  sE     19-,.)%%t'='='L'L	
r   c                 n    t        j                         }| j                  t        |j                  d       y)z
        When L{NetstringReceiver.stringReceived} is not overridden in a
        subclass, calling it raises C{NotImplementedError}.
        r   N)r   NetstringReceiverr   r   r   r   s     r   !test_stringReceivedNotImplementedz8NetstringReceiverTests.test_stringReceivedNotImplemented  s+    
 '')-u/C/CUKr   N)r(   r)   r*   r+   r   r   r   r   r   rk   r   r  r  r  r
  r  r  r  r  r  r  r  r$  r&  r)  r0  r3  r8  r:  r=  r-   r   r   r   r   F  s     UGN H>
7$ABCE666666CKC
H	6JJ



Lr   r   c                       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 Zd	 Zd
 Zd Zd Zd Zy)IntNTestCaseMixinz4
    TestCase mixin for int-prefixed protocols.
    Nr   r   r   r   partialStringsc           	      (   | j                         }| j                  D ]M  }t        t        j                  |j
                  t        |            |z         D ]  }|j                  |        O | j                  |j                  | j                         y)z>
        Test receiving data find the same data send.
        N)
r   r   r   structpackstructFormatrL   rb   rc   r6   )r   r   rj   r   s       r   test_receivezIntNTestCaseMixin.test_receive(  sw      	"Av{{1>>3q6BQFG "q!"	" 	T\\2r   c                     | j                   D ]O  }| j                         }t        |      D ]  }|j                  |        | j	                  |j
                  g        Q y)zK
        Send partial data, nothing should be definitely received.
        N)r@  r   r   rb   rc   r6   r   s       r   test_partialzIntNTestCaseMixin.test_partial2  sZ     $$ 	-A  "Aq\ "q!"QZZ,		-r   c                     | j                         }|j                  d       | j                  |j                  j	                         t        j                  |j                  d      dz          y)z2
        Test sending data over protocol.
           bbbbbbbbbbbbbbbb   N)r   r   rc   rG   r   rB  rC  rD  r   r   s     r   	test_sendzIntNTestCaseMixin.test_send<  sR     	YKKQ^^R!@9!L	
r   c                     g }| j                         }|j                  |_        d|_        |j	                  t        j                  |j                  d             | j                  |dg       y)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.
        r\   r5  N)	r   r   lengthLimitExceededrO   rb   rB  rC  rD  rc   )r   rE   r   s      r   test_lengthLimitExceededz*IntNTestCaseMixin.test_lengthLimitExceededF  sW      &	v{{1>>267"&r   c                     | j                         }d|_        |j                  t        j                  |j
                  d      dz          | j                  |j                  g        y)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}.
        r\   r5  s   xxxxxxxxxxxN)r   rO   rb   rB  rC  rD  rc   r6   rK  s     r   test_longStringNotDeliveredz-IntNTestCaseMixin.test_longStringNotDeliveredS  sM     	v{{1>>26BCR(r   c                 n    t        j                         }| j                  t        |j                  d       y)z
        When L{IntNStringReceiver.stringReceived} is not overridden in a
        subclass, calling it raises C{NotImplementedError}.
        r   N)r   IntNStringReceiverr   r   r   r   s     r   r=  z3IntNTestCaseMixin.test_stringReceivedNotImplemented^  s+    
 ((*-u/C/CUKr   )r(   r)   r*   r+   r   r   r   r   r   r   r   r@  rE  rG  rL  rO  rQ  r=  r-   r   r   r?  r?    sl     59H18%)GXd5k"),0NHT%[)0,0NHT%[)03-
'	)Lr   r?  c                   .    e Zd ZdZd Zd Zd Zd Zd Zy)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                 Z    t        j                  |j                  t        |            |z   S )zg
        Return C{data} prefixed with message length in C{protocol.structFormat}
        form.
        )rB  rC  rD  rL   )r   r   r&   s      r   makeMessagezRecvdAttributeMixin.makeMessagen  s$    
 {{800#d)<tCCr   c                     g | j                         fd}|_        t        j                  j                  d      dz   }t        j                  j                  d      dz   }j                  ||z          | j                  |g       y)z
        In stringReceived, recvd contains the remaining data that was passed to
        dataReceived that was not part of the current message.
        c                 <    j                  j                         y r   r   recvd)receivedStringr   results    r   r   zKRecvdAttributeMixin.test_recvdContainsRemainingData.<locals>.stringReceived}  s    MM!''"r         aaaaas   bbbbN)r   r   rB  rC  rD  rb   rc   )r   r   completeMessageincompleteMessager   r]  s       @@r   test_recvdContainsRemainingDataz3RecvdAttributeMixin.test_recvdContainsRemainingDatau  s    
 	# * ++anna8HE"KK:hG	)::;"3!45r   c                   	 | j                         g 	d}| j                  |      	fd}|_        d}d}| j                  |      }| j                  |      }j                  ||z          | j	                  	||g       y)z
        In stringReceived, if recvd is changed, messages should be parsed from
        it rather than the input to dataReceived.
        s   cccccc                 :    s_         j                  |        y r   )r[  r   )r\  messageCr   r]  s    r   r   z=RecvdAttributeMixin.test_recvdChanged.<locals>.stringReceived  s    "MM.)r   r_  s   bbbbbN)r   rW  r   rb   rc   )
r   payloadCr   payloadApayloadBmessageAmessageBre  r   r]  s
          @@@r   test_recvdChangedz%RecvdAttributeMixin.test_recvdChanged  s    
 ##Ax0	*
 *##Ax0##Ax0	x(*+(H!56r   c                    | j                         g }d| j                  D ]4  }|j                  | j                  |             |j                         6 g fd}|_        j                  dj                  |             j                  d       | j                  | j                         | j                  j                  d       y)z
        Data already parsed by L{IntNStringReceiver.dataReceived} is not
        reparsed if C{stringReceived} consumes some of the
        L{IntNStringReceiver.recvd} buffer.
        s       c                 b    j                  |        j                  t              d  _        y r   )r   r[  rL   )r\  SWITCHr   r]  s    r   r   z:RecvdAttributeMixin.test_switching.<locals>.stringReceived  s%    MM.)++c&km4EKr   r      N)	r   r   r   rW  r   rb   r   rc   r[  )r   mixrj   r   rn  r   r]  s       @@@r   test_switchingz"RecvdAttributeMixin.test_switching  s       "$ 	AJJt''q12JJv	 	5  .388C=) 	7#.g.r   c                    | j                         d}t        |      dz
  _        | j                  |      }g fd}|_        j                  |       | j                  d   t        |             | j                  d   |       y)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                 ^    j                  |        j                  j                         y r   rZ  )rE   r   r]  s    r   rN  zPRecvdAttributeMixin.test_recvdInLengthLimitExceeded.<locals>.lengthLimitExceeded  s    MM&!MM%++&r   r   N)r   rL   rO   rW  rN  rb   rc   )r   DATAmessagerN  r   r]  s       @@r   test_recvdInLengthLimitExceededz3RecvdAttributeMixin.test_recvdInLengthLimitExceeded  s       "t9q=""5$/	' %8!7#CI.G,r   N)	r(   r)   r*   r+   rW  rb  rk  rq  rv  r-   r   r   rU  rU  g  s!    D6$7./8-r   rU  c                       e Zd ZdZy)	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   rx  rx        r   rx  c                   0    e Zd ZdZeZddgZdgZg dZd Z	y)
Int32Testsz/
    Test case for int32-prefixed protocol
    rZ   rI  s
      aaaaaa)s         hello therer   c                     | j                         }|j                  d       | j                  |j                  j	                         d       |j                  d       | j                  |j                  dg       y)z?
        Test specific behavior of the 32-bits length.
        r   s      foos      ubar   ubarNr   r   rc   rG   r   rb   r6   rK  s     r   	test_datazInt32Tests.test_data  s_     	V**,.DE	./gY/r   N)
r(   r)   r*   r+   rx  r   r   r   r@  r  r-   r   r   r|  r|    s*     HYG/0N;N0r   r|  c                       e Zd ZdZy)	TestInt16z
    A L{basic.Int16StringReceiver} storing received strings in an array.

    @ivar received: array holding received strings.
    Nry  r-   r   r   r  r    rz  r   r  c                   6    e Zd ZdZeZddgZdgZg dZd Z	d Z
y)	
Int16Testsz/
    Test case for int16-prefixed protocol
    rZ   rI  s    aaaaaa)    r}  r   c                     | j                         }|j                  d       | j                  |j                  j	                         d       |j                  d       | j                  |j                  dg       y)z?
        Test specific behavior of the 16-bits length.
        r   s    foos    ubarr  Nr  rK  s     r   r  zInt16Tests.test_data   s]     	V**,n=	'gY/r   c                     | j                         }dd|j                  dz  z  dz   z  }| j                  t        |j                  |       yzA
        Send too much data: that should cause an error.
        r#  r      r#   Nr   prefixLengthr   AssertionErrorr   r   r   tooSends      r   test_tooLongSendzInt16Tests.test_tooLongSend
  E     ! 23a78.!,,@r   N)r(   r)   r*   r+   r  r   r   r   r@  r  r  r-   r   r   r  r    s0     HYG'(N3N0Ar   r  c                       e Zd ZdZy)TestInt8z
    A L{basic.Int8StringReceiver} storing received strings in an array.

    @ivar received: array holding received strings.
    Nry  r-   r   r   r  r    rz  r   r  c                   6    e Zd ZdZeZddgZdgZg dZd Z	d Z
y)		Int8Testsz.
    Test case for int8-prefixed protocol
    rZ   rI  s     aaaaaa)   s   dzadzr   c                     | j                         }|j                  d       | j                  |j                  j	                         d       |j                  d       | j                  |j                  dg       y)z>
        Test specific behavior of the 8-bits length.
        r   s   foos   ubarr  Nr  rK  s     r   r  zInt8Tests.test_data%  s]     	V**,j9	{#gY/r   c                     | j                         }dd|j                  dz  z  dz   z  }| j                  t        |j                  |       yr  r  r  s      r   r  zInt8Tests.test_tooLongSend/  r  r   N)r(   r)   r*   r+   r  r   r   r   r@  r  r  r-   r   r   r  r    s0     HYG'(N-N0Ar   r  c                   0    e Zd ZdZdZdZd Zd Zd Zd Z	y)OnlyProducerTransportzm
    Transport which isn't really a transport, just looks like one to
    someone not looking very hard.
    Fc                     g | _         y r   r   r   s    r   r   zOnlyProducerTransport.__init__A  s	    	r   c                     d| _         y )NTpausedr   s    r   r@   z$OnlyProducerTransport.pauseProducingD  s	    r   c                     d| _         y )NFr  r   s    r   rB   z%OnlyProducerTransport.resumeProducingG  s	    r   c                 :    | j                   j                  |       y r   )r&   r   )r   r   s     r   r   zOnlyProducerTransport.writeJ  s    		r   N)
r(   r)   r*   r+   r  r   r   r@   rB   r   r-   r   r   r  r  8  s'    
 FM r   r  c                       e Zd ZdZd Zy)ConsumingProtocolzC
    Protocol that really, really doesn't want any more bytes.
    c                 Z    | j                   j                  |       | j                          y r   )rG   r   r@   r   s     r   r!   zConsumingProtocol.lineReceivedS  s     T"r   N)r(   r)   r*   r+   r!   r-   r   r   r  r  N  s    r   r  c                       e Zd ZdZd Zy)ProducerTestszM
    Tests for L{basic._PausableMixin} and L{basic.LineReceiver.paused}.
    c                    t               }t               }|j                  |       |j                  d       | j	                  |j
                  g        | j                  |j                         | j                  |j                         |j                  d       | j	                  |j
                  dg       | j                  |j                         | j                  |j                         |j                          | j	                  |j
                  dg       | j                  |j                         | j                  |j                         |j                  d       | j	                  |j
                  ddg       | j                  |j                         | j                  |j                         |j                          | j	                  |j
                  g d       | j                  |j                         | j                  |j                         |j                  d       | j	                  |j
                  g d       | j                  |j                         | j                  |j                         |j                          | j	                  |j
                  g d       | j                  |j                         | j                  |j                         |j                          | j	                  |j
                  g d       | j                  |j                         | j                  |j                         y	)
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   )r  r   r   s	   goodbye
)r  r   r   r   N)
r  r  r_   rb   rc   r&   r   r  r   rB   )r   prg   s      r   test_pauseResumezProducerTests.test_pauseResume]  sN    !#	 	
z"$"" 	
|$/!23!! 	
/!23"" 	
,-/8!<=!! 	
!FG!! 	
~&!FG!! 	
!RS!! 	
!RS""r   N)r(   r)   r*   r+   r  r-   r   r   r  r  X  s    A#r   r  c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	FileSenderTestsz(
    Tests for L{basic.FileSender}.
    c                 j    t        j                         }| j                  t        t        |             y)zP
        L{basic.FileSender} implements the L{IPullProducer} interface.
        N)r   
FileSenderr   r   r
   )r   senders     r   test_interfacezFileSenderTests.test_interface  s%     !!#Y78r   c                     t        d      }t        j                         }t        j                         }|j                  ||       | j                  |j                  |       | j                  |j                         y)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   r  beginFileTransferrc   producerr   	streaming)r   sourceconsumerr  s       r   test_producerRegisteredz'FileSenderTests.test_producerRegistered  sd    
 ) 002!!#  2**F3++,r   c                    t        d      }t        j                         }t        j                         }|j                  ||      }|j                          |j                          | j                  |j                         | j                  d| j                  |             | j                  d|j                                y)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   r  r  rB   assertIsNoner  rc   successResultOfr   r   r  r  r  ds        r   test_transferzFileSenderTests.test_transfer  s     ) 002!!#$$VX6  (++,t33A67(..*:;r   c                 ^   t        d      }t        j                         }t        j                         }d|_        |j                  ||      }|j                          | j                  d|j                                |j                          | j                  d|j                                |j                          | j                  d|j                                |j                          | j                  d| j                  |             | j                  d|j                                y)zj
        L{basic.FileSender} reads at most C{CHUNK_SIZE} every time it resumes
        producing.
        r  r=   s   Tests   Test conr  N)r   r   r   r   r  
CHUNK_SIZEr  rB   rc   r   r  r  s        r   test_transferMultipleChunksz+FileSenderTests.test_transferMultipleChunks  s    
 ) 002!!#$$VX6 (.."23 hnn&67 (..*:; t33A67(..*:;r   c                 X   d }t        d      }t        j                         }t        j                         }|j                  |||      }|j                          |j                          | j                  d| j                  |             | j                  d|j                                y)z
        L{basic.FileSender.beginFileTransfer} takes a C{transform} argument
        which allows to manipulate the data on the fly.
        c                 "    | j                         S r   )swapcase)chunks    r   	transformz=FileSenderTests.test_transferWithTransform.<locals>.transform  s    >>##r   r     Ts   tEST CONTENTN)
r   r   r   r   r  r  rB   rc   r  r   )r   r  r  r  r  r  s         r   test_transferWithTransformz*FileSenderTests.test_transferWithTransform  s    	$ ) 002!!#$$VXyA  t33A67(..*:;r   c                 D   t        d      }t        j                         }t        j                         }|j                  ||      }|j                          | j                  |      }|j                  t               | j                  dt        |j                               y)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   r  r  rC   failureResultOftrap	Exceptionrc   strr   )r   r  r  r  r  failures         r   test_abortedTransferz$FileSenderTests.test_abortedTransfer  s~     ) 002!!#$$VX6&&q)Y>GMM@RSr   N)
r(   r)   r*   r+   r  r  r  r  r  r  r-   r   r   r  r    s&    9
-<$<.<(Tr   r  );r+   rB  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   rR   SynchronousTestCaserW   r   r   r   r   r<  r   r   r   r?  rU  Int32StringReceiverrx  r|  Int16StringReceiverr  r  Int8StringReceiverr  r  r  r  r  TestCaser  r-   r   r   <module>r     s  
  
  ' ' . + 1 4 # + * & "#++ #0E:## E:P#U++ #*uJ44 uJp$%"4"4 $.L1(*F*F L1^)JH88 )JX  Iu66  7 72ULX99? ULpFL FLRg- g-T	544 0--/@BU 0*	544 A--/@BU A:y%22 A,,.?AT A:   ,** F#H00 F#RdTh'' dTr   