+
    Dfj;                        R t ^ RIHt ^ RIHtHtHtHtHt ^ RI	H
t
HtHtHtHtHtHtHt ^ RIHt ^ RIHtHtHtHtHtHt ^ RIHtHt ^ RIHt ^ RI H!t! ^ R	I"H#t# ^ R
I$H%t% ^ RI&H't'H(t( ^ RI)H*t* ^RI+H,t,H-t-H.t.H/t/H+t+ ^RI0H1t1H2t2 ]! R4      t3 ! R R]*4      t4 ! R R]*4      t5 ! R R]#4      t6R R lt7 ! R R]*4      t8 ! R R]*4      t9R# )z*
Tests for L{twisted.trial._dist.stream}.
)Random)	AwaitableDictListTypeVarUnion)all_ofassert_thatcallingequal_to
has_lengthis_less_than_or_equal_toraises)given)binaryintegersjustlistsrandomstext)Deferredfail)	IProtocol)Protocol)AMP)Failure)FakeTransportconnect)SynchronousTestCase)
StreamOpenStreamReceiverStreamWritechunkstream)HasSumIsSequenceOfTc                      a  ] tR t^"t o Rt]! ]! ]! ]! 4       4      4      ]! 4       4      V 3R lR l4       t	]! ]
! 4       ]! R4      4      V 3R lR l4       t]! ]
! 4       4      V 3R lR l4       tV 3R	 lR
 ltRtV tR# )StreamReceiverTestsz
Tests for L{StreamReceiver}
c                J   < V ^8  d   QhRS[ S[ S[,          ,          RS[RR/# )   streamsrandomreturnN)r   bytesr   )format__classdict__s   "F/usr/lib/python3/dist-packages/twisted/trial/_dist/test/test_stream.py__annotate__ StreamReceiverTests.__annotate__(   s,     = =4U+< =f =QU =    c                   \        4       pV Uu. uF  qCP                  4       NK  	  ppVP                  V4       \        \	        WQ4      4      pVP                  4        F  w  rxV F  p	VP                  Wy4       K  	  K!  	  VP                  V4       V Uu/ uF  qwVP                  V4      bK  	  p
p\        V
\        \        V4      4      4       R# u upi u upi )z{
All data passed to L{StreamReceiver.write} is returned by a call to
L{StreamReceiver.finish} with a matching C{streamId}.
N)r!   openshuffledictzipitemswritefinishr	   r   r   )selfr,   r-   receiver_	streamIdsexpectedDatastreamIdstringss
actualDatas   &&&        r2   test_streamReceived'StreamReceiverTests.test_streamReceived'   s     "#.56g]]_g	6 	y!C	34!-!3!3!5Hx+  "6
 	y!JST)h 99)
TJH\$: ;< 7 Us   CCdatac                *   < V ^8  d   QhRS[ RS[RR/# )r+   rC   rI   r.   N)intstr)r0   r1   s   "r2   r3   r4   @   s'     Y Yc Y Y Yr5   c                    \        4       p\        \        VP                  4      P	                  W4      \        \        4      4       R# )zj
L{StreamReceiver.write} raises L{KeyError} if called with a
streamId not associated with an open stream.
N)r!   r	   r
   r<   	with_argsr   KeyError)r>   rC   rI   r?   s   &&& r2   test_writeBadStreamId)StreamReceiverTests.test_writeBadStreamId?   s/     "#GHNN+55hEvhGWXr5   c                $   < V ^8  d   QhRS[ RR/# )r+   rC   r.   N)rK   )r0   r1   s   "r2   r3   r4   I   s     T Ts Tt Tr5   c                    \        4       p\        \        VP                  4      P	                  V4      \        \        4      4       R# )zk
L{StreamReceiver.finish} raises L{KeyError} if called with a
streamId not associated with an open stream.
N)r!   r	   r
   r=   rN   r   rO   )r>   rC   r?   s   && r2   test_badFinishStreamId*StreamReceiverTests.test_badFinishStreamIdH   s/     "#GHOO,66x@&BRSr5   c                   < V ^8  d   QhRR/# )r+   r.   N )r0   r1   s   "r2   r3   r4   Q   s     T T$ Tr5   c                    \        4       pVP                  4       pVP                  V4       \        \	        VP                  4      P                  V4      \        \        4      4       R# )z9
L{StreamReceiver.finish} removes the identified stream.
N)r!   r7   r=   r	   r
   rN   r   rO   )r>   r?   rC   s   &  r2   test_finishRemovesStream,StreamReceiverTests.test_finishRemovesStreamQ   sF     "#==?!GHOO,66x@&BRSr5   rW   N)__name__
__module____qualname____firstlineno____doc__r   r   r   r   rG   r   r   rP   rT   rY   __static_attributes____classdictcell__r1   s   @r2   r)   r)   "   s~      5vx!79-= .=. 8:tF|$Y %Y 8:T TT Tr5   r)   c                   \   a  ] tR t^[t o Rt]! ]! 4       ]! ^R7      R7      R 4       tRt	V t
R# )
ChunkTestsz
Tests for ``chunk``.
)	min_value)rI   	chunkSizec                    \        \        W4      4      p\        V\        \	        \        \        V4      4      4      \        \        V4      VR,          4      4      4       R# )z
L{chunk} returns an iterable of L{str} where each element is no
longer than the given limit.  The concatenation of the strings is also
equal to the original input string.
:N    NN)	listr#   r	   r   r&   r   r   r%   r   )r>   rI   rf   chunkss   &&& r2   
test_chunkChunkTests.test_chunk`   sP     eD,-4Y?@ x~tBx0		
r5   rW   N)r[   r\   r]   r^   r_   r   r   r   rk   r`   ra   rb   s   @r2   rd   rd   [   s,      (Q"78
 9
r5   rd   c                      a  ] tR t^st o RtV 3R lR lt]P                  V 3R lR l4       t]	P                  V 3R lR l4       t
RtV tR	# )
AMPStreamReceiverz.
A simple AMP interface to L{StreamReceiver}.
c                $   < V ^8  d   QhRS[ RR/# )r+   r,   r.   N)r!   )r0   r1   s   "r2   r3   AMPStreamReceiver.__annotate__x   s       4 r5   c                    Wn         R # Nr,   )r>   r,   s   &&r2   __init__AMPStreamReceiver.__init__x   s    r5   c                6   < V ^8  d   QhRS[ S[S[3,          /# r+   r.   )r   rL   object)r0   r1   s   "r2   r3   rp   |   s     1 1Df- 1r5   c                :    R V P                   P                  4       /# )rC   )r,   r7   r>   s   &r2   
streamOpenAMPStreamReceiver.streamOpen{   s    DLL--/00r5   c                B   < V ^8  d   QhRS[ RS[RS[S[S[3,          /# )r+   rC   rI   r.   )rK   r/   r   rL   rx   )r0   r1   s   "r2   r3   rp      s+      C u c6k9J r5   c                <    V P                   P                  W4       / # rr   )r,   r<   )r>   rC   rI   s   &&&r2   streamWriteAMPStreamReceiver.streamWrite   s    8*	r5   rs   N)r[   r\   r]   r^   r_   rt   r    	responderr{   r"   r   r`   ra   rb   s   @r2   rn   rn   s   sH       1 1  r5   rn   c                ^    V ^8  d   QhR\         R\         R\        \        ,          R\        /# )r+   serverclientinteractionr.   )r   r   r'   )r0   s   "r2   r3   r3      s-     ? ?Y ?	 ?	! ?QR ?r5   c           
     h  aaa RoR V3R llpR VV3R llp\        V \        V RR7      V\        VRR7      4      p\        P                  ! V! 4       4      pVP	                  V4       VP                  4        S'       d)   \        S\        4      '       d   SP                  4        S# \        R4      h)	zG
Let C{server} and C{client} exchange bytes while C{interaction} runs.
Fc                $    V ^8  d   QhR\         /# rw   )r'   )r0   s   "r2   r3   interact.<locals>.__annotate__   s     ! ! !r5   c                  $   <"   S G R j  xL
 #  L5irr   rW   )r   s   r2   to_coroutineinteract.<locals>.to_coroutine   s         s   c                J    V ^8  d   QhR\         \        \        3,          RR/# )r+   rr.   N)r   r   r'   )r0   s   "r2   r3   r      s#      %
+  r5   c                    < R oV oR# )TNrW   )r   finishedresults   &r2   collect_result interact.<locals>.collect_result   s    r5   T)isServerz'Interaction failed to produce a result.)
r   r   r   fromCoroutineaddBothflush
isinstancer   raiseException	Exception)	r   r   r   r   r   pumpinteractingr   r   s	   &&f    @@r2   interactr      s     H! ! 
 ft,fu-	D ((8K'JJLfg&&!!#
=
>>r5   c                   0   a  ] tR t^t o RtR tR tRtV tR# )InteractTestsz(
Tests for the test helper L{interact}.
c           
          ! R R\         4      pV P                  V4      ;_uu_ 4        \        \        4       \        4       \	        V! 4       4      4       RRR4       R#   + '       g   i     R# ; i)zO
If the interaction results in a failure then L{interact} raises an
exception.
c                       ] tR t^tRtR# )6InteractTests.test_failure.<locals>.ArbitraryExceptionrW   N)r[   r\   r]   r^   r`   rW   r5   r2   ArbitraryExceptionr      s    r5   r   N)r   assertRaisesr   r   r   )r>   r   s   & r2   test_failureInteractTests.test_failure   sJ    	 	 122XZT2D2F-GH 3222s   ,AA0	c                    V P                  \        4      ;_uu_ 4        \        \        4       \        4       \	        4       4       RRR4       R#   + '       g   i     R# ; i)zT
If the interaction fails to produce a result then L{interact} raises
an exception.
N)r   r   r   r   r   rz   s   &r2   test_incompleteInteractTests.test_incomplete   s6    
 y))XZXZ8 *)))s   &AA	rW   N)	r[   r\   r]   r^   r_   r   r   r`   ra   rb   s   @r2   r   r      s     
I9 9r5   r   c                   b   a  ] tR t^t o Rt]! ]! ]! 4       4      4      V 3R lR l4       tRt	V t
R# )StreamTestsz
Tests for L{stream}.
c                4   < V ^8  d   QhRS[ S[,          RR/# )r+   rj   r.   N)r   r/   )r0   r1   s   "r2   r3   StreamTests.__annotate__   s#     
E 
E$u+ 
E$ 
Er5   c           
         \        4       p\        4       p\        \        V4      V\	        V\        V4      4      4      p\        VP                  V4      \        \        V4      4      4       R# )zg
All of the chunks passed to L{stream} are sent in order over a
stream using the given AMP connection.
N)
r   r!   r   rn   r$   iterr	   r=   r   r   )r>   rj   senderr,   rC   s   &&   r2   test_streamStreamTests.test_stream   sS      "g&vtF|0L
 	GNN8,c(62B.CDr5   rW   N)r[   r\   r]   r^   r_   r   r   r   r   r`   ra   rb   s   @r2   r   r      s+      5?
E 
Er5   r   N):r_   r-   r   typingr   r   r   r   r   hamcrestr   r	   r
   r   r   r   r   r   
hypothesisr   hypothesis.strategiesr   r   r   r   r   r   twisted.internet.deferr   r   twisted.internet.interfacesr   twisted.internet.protocolr   twisted.protocols.ampr   twisted.python.failurer   twisted.test.iosimr   r   twisted.trial.unittestr   r$   r    r!   r"   r#   matchersr%   r&   r'   r)   rd   rn   r   r   r   rW   r5   r2   <module>r      s     8 8	 	 	  N N 1 1 . % * 5 6 K K *CL6T- 6Tr
$ 
0 $?B9' 94E% Er5   