+
    üÐjb*  ã                  ó  € R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
HtHt ^ RIHt ^ RIHt ^ RIHtHtHtHtHt ^ R	IHt  ! R
 R]4      t]! ]4       ! R R4      4       t ! R R]4      t ! R R]4      t ! R R]4      tR# )z"
Tests for L{twisted.test.iosim}.
)Úannotations)ÚLiteral)Úimplementer)ÚIPushProducer)ÚClientFactoryÚFactoryÚProtocol)ÚClock)ÚMemoryReactor)ÚConnectionCompleterÚFakeTransportÚIOPumpÚconnectÚconnectedServerAndClient)ÚTestCasec                  ó>   € ] tR t^tRtR R ltR R ltR R ltRtR	# )
ÚFakeTransportTestsz
Tests for L{FakeTransport}.
c               ó   € V ^8„  d   QhRR/# ©é   ÚreturnÚNone© )Úformats   "Ú9/usr/lib/python3/dist-packages/twisted/test/test_iosim.pyÚ__annotate__ÚFakeTransportTests.__annotate__    s   € ÷ 	0ñ 	0 tñ 	0ó    c                ó"  € \        \        4       R4      p\        \        4       R4      pV P                  VP                  \        4       V P                  VP                  \        4       V P                  VP                  VP                  4       R# )zM
Each L{FakeTransport} receives a serial number that uniquely identifies
it.
TFN)r   ÚobjectÚassertIsInstanceÚserialÚintÚassertNotEqual)ÚselfÚaÚbs   &  r   Útest_connectionSerialÚ(FakeTransportTests.test_connectionSerial    s`   € ô
 œ&›( DÓ)ˆÜœ&›( EÓ*ˆØ×Ñ˜aŸh™h¬Ô,Ø×Ñ˜aŸh™h¬Ô,Ø×Ñ˜AŸH™H a§h¡hÖ/r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r   +   s   € ÷ 
6ñ 
6 Dñ 
6r   c                óÌ   € \        \        4       R4      pVP                  R4       VP                  . RO4       V P	                  RP                  VP                  4      R4       R# )zT
L{FakeTransport.writeSequence} will write a sequence of L{bytes} to the
transport.
Fó   ar   s   abcdN)ó   bó   có   d)r   r   ÚwriteÚwriteSequenceÚassertEqualÚjoinÚstream©r$   r%   s   & r   Útest_writeSequenceÚ%FakeTransportTests.test_writeSequence+   sG   € ô
 œ&›( EÓ*ˆà	�‰�ŒØ	�‰Ò*Ô+à×Ñ˜Ÿ™ !§(¡(Ó+¨WÖ5r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r   7   s   € ÷ 
8ñ 
8 dñ 
8r   c                óè   € \        \        4       R4      pVP                  R4       VP                  4        VP                  R4       V P	                  RP                  VP                  4      R4       R# )zp
L{FakeTransport.write} will accept writes after transport was closed,
but the data will be silently discarded.
Fs   befores   afterr   N)r   r   r/   ÚloseConnectionr1   r2   r3   r4   s   & r   Útest_writeAfterCloseÚ'FakeTransportTests.test_writeAfterClose7   sS   € ô
 œ&›( EÓ*ˆØ	�‰�	ÔØ	×ÑÔØ	�‰�Ôà×Ñ˜Ÿ™ !§(¡(Ó+¨YÖ7r   r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r'   r5   r:   Ú__static_attributes__r   r   r   r   r      s   † ñõ	0õ
6÷
8ñ 
8r   r   c                  óB   € ] tR t^DtRtRtR R ltR R ltR R ltR	t	R
# )ÚStrictPushProducerzw
An L{IPushProducer} implementation which produces nothing but enforces
preconditions on its state transition methods.
Úrunningc               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   ÚStrictPushProducer.__annotate__M   s   € ÷  ñ  ˜tñ  r   c                	óL   € V P                   R 8X  d   \        R4      hR V n         R# )Ústoppedz)Cannot stop already-stopped IPushProducerN©Ú_stateÚ
ValueError©r$   s   &r   ÚstopProducingÚ StrictPushProducer.stopProducingM   s!   € Ø�;‰;˜)Ô#ÜÐHÓIÐIØˆŽr   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   rF   R   s   € ÷ ñ  ñ r   c                	óh   € V P                   R 8w  d   \        RV P                    R24      hRV n         R# )rD   zCannot pause ú IPushProducerÚpausedNrI   rL   s   &r   ÚpauseProducingÚ!StrictPushProducer.pauseProducingR   s-   € Ø�;‰;˜)Ô#Ü˜}¨T¯[©[¨M¸ÐHÓIÐIØˆŽr   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   rF   W   s   € ÷  ñ   ñ  r   c                	óh   € V P                   R 8w  d   \        RV P                    R24      hRV n         R# )rR   zCannot resume rQ   rD   NrI   rL   s   &r   ÚresumeProducingÚ"StrictPushProducer.resumeProducingW   s-   € Ø�;‰;˜(Ô"Ü˜~¨d¯k©k¨]¸.ÐIÓJÐJØˆŽr   )rJ   N)
r<   r=   r>   r?   r@   rJ   rM   rS   rW   rA   r   r   r   rC   rC   D   s"   † ñð
 €Fõ õ
÷
 ñ  r   rC   c                  óþ   € ] tR t^]tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR  R! ltR" R# ltR$ R% ltR& R' ltR(tR)# )*ÚStrictPushProducerTestsz"
Tests for L{StrictPushProducer}.
c               ó   € V ^8„  d   QhRR/# ©r   r   rC   r   )r   s   "r   r   Ú$StrictPushProducerTests.__annotate__b   s   € ÷ $ñ $Ð,ñ $r   c                ó   € \        4       # )zX
@return: A new L{StrictPushProducer} which has not been through any state
    changes.
)rC   rL   s   &r   Ú_initialÚ StrictPushProducerTests._initialb   s   € ô
 "Ó#Ð#r   c               ó   € V ^8„  d   QhRR/# r\   r   )r   s   "r   r   r]   i   s   € ÷ ñ Ð,ñ r   c                ó:   € \        4       pVP                  4        V# )z0
@return: A new, stopped L{StrictPushProducer}.
)rC   rM   ©r$   Úproducers   & r   Ú_stoppedÚ StrictPushProducerTests._stoppedi   s   € ô &Ó'ˆØ×ÑÔ Øˆr   c               ó   € V ^8„  d   QhRR/# r\   r   )r   s   "r   r   r]   q   s   € ÷ ñ Ð+ñ r   c                ó:   € \        4       pVP                  4        V# )z/
@return: A new, paused L{StrictPushProducer}.
)rC   rS   rc   s   & r   Ú_pausedÚStrictPushProducerTests._pausedq   s   € ô &Ó'ˆØ×ÑÔ!Øˆr   c               ó   € V ^8„  d   QhRR/# r\   r   )r   s   "r   r   r]   y   s   € ÷ ñ Ð,ñ r   c                óZ   € \        4       pVP                  4        VP                  4        V# )zI
@return: A new L{StrictPushProducer} which has been paused and resumed.
)rC   rS   rW   rc   s   & r   Ú_resumedÚ StrictPushProducerTests._resumedy   s)   € ô &Ó'ˆØ×ÑÔ!Ø× Ñ Ô"Øˆr   c               ó    € V ^8„  d   QhRRRR/# ©r   rd   rC   r   r   r   )r   s   "r   r   r]   ‚   ó   € ÷ 5ñ 5Ð&8ð 5¸Tñ 5r   c                ó>   € V P                  VP                  R4       R# )z‰
Assert that the given producer is in the stopped state.

@param producer: The producer to verify.
@type producer: L{StrictPushProducer}
rH   N©r1   rJ   rc   s   &&r   ÚassertStoppedÚ%StrictPushProducerTests.assertStopped‚   ó   € ð 	×Ñ˜Ÿ™¨)Ö4r   c               ó    € V ^8„  d   QhRRRR/# rp   r   )r   s   "r   r   r]   ‹   s   € ÷ 4ñ 4Ð%7ð 4¸Dñ 4r   c                ó>   € V P                  VP                  R4       R# )zˆ
Assert that the given producer is in the paused state.

@param producer: The producer to verify.
@type producer: L{StrictPushProducer}
rR   Nrs   rc   s   &&r   ÚassertPausedÚ$StrictPushProducerTests.assertPaused‹   s   € ð 	×Ñ˜Ÿ™¨(Ö3r   c               ó    € V ^8„  d   QhRRRR/# rp   r   )r   s   "r   r   r]   ”   rq   r   c                ó>   € V P                  VP                  R4       R# )z‰
Assert that the given producer is in the running state.

@param producer: The producer to verify.
@type producer: L{StrictPushProducer}
rD   Nrs   rc   s   &&r   ÚassertRunningÚ%StrictPushProducerTests.assertRunning”   rv   r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   �   s   € ÷ Eñ E 4ñ Er   c                ób   € V P                  \        V P                  4       P                  4       R# )zb
L{StrictPushProducer.stopProducing} raises L{ValueError} if called when
the producer is stopped.
N)ÚassertRaisesrK   re   rM   rL   s   &r   Útest_stopThenStopÚ)StrictPushProducerTests.test_stopThenStop�   s    € ð
 	×Ñœ* d§m¡m£o×&CÑ&CÖDr   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   ¤   s   € ÷ Fñ F Dñ Fr   c                ób   € V P                  \        V P                  4       P                  4       R# )zc
L{StrictPushProducer.pauseProducing} raises L{ValueError} if called when
the producer is stopped.
N)r�   rK   re   rS   rL   s   &r   Útest_stopThenPauseÚ*StrictPushProducerTests.test_stopThenPause¤   s    € ð
 	×Ñœ* d§m¡m£o×&DÑ&DÖEr   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   «   s   € ÷ Gñ G Tñ Gr   c                ób   € V P                  \        V P                  4       P                  4       R# )zd
L{StrictPushProducer.resumeProducing} raises L{ValueError} if called when
the producer is stopped.
N)r�   rK   re   rW   rL   s   &r   Útest_stopThenResumeÚ+StrictPushProducerTests.test_stopThenResume«   s    € ð
 	×Ñœ* d§m¡m£o×&EÑ&EÖFr   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   ²   s   € ÷ %ñ % Dñ %r   c                óh   € V P                  4       pVP                  4        V P                  V4       R# )zV
L{StrictPushProducer} is stopped if C{stopProducing} is called on a paused
producer.
N)ri   rM   rt   rc   s   & r   Útest_pauseThenStopÚ*StrictPushProducerTests.test_pauseThenStop²   s)   € ð
 —<‘<“>ˆØ×ÑÔ Ø×Ñ˜8Ö$r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   »   s   € ÷ ?ñ ? Tñ ?r   c                óf   € V P                  4       pV P                  \        VP                  4       R# )z[
L{StrictPushProducer.pauseProducing} raises L{ValueError} if called on a
paused producer.
N)ri   r�   rK   rS   rc   s   & r   Útest_pauseThenPauseÚ+StrictPushProducerTests.test_pauseThenPause»   s%   € ð
 —<‘<“>ˆØ×Ñœ* h×&=Ñ&=Ö>r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   Ã   s   € ÷ %ñ % dñ %r   c                óh   € V P                  4       pVP                  4        V P                  V4       R# )zX
L{StrictPushProducer} is resumed if C{resumeProducing} is called on a
paused producer.
N)ri   rW   r}   rc   s   & r   Útest_pauseThenResumeÚ,StrictPushProducerTests.test_pauseThenResumeÃ   s)   € ð
 —<‘<“>ˆØ× Ñ Ô"Ø×Ñ˜8Ö$r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   Ì   s   € ÷ %ñ % Tñ %r   c                óh   € V P                  4       pVP                  4        V P                  V4       R# )zW
L{StrictPushProducer} is stopped if C{stopProducing} is called on a
resumed producer.
N)rm   rM   rt   rc   s   & r   Útest_resumeThenStopÚ+StrictPushProducerTests.test_resumeThenStopÌ   ó)   € ð
 —=‘=“?ˆØ×ÑÔ Ø×Ñ˜8Ö$r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   Õ   s   € ÷ $ñ $ dñ $r   c                óh   € V P                  4       pVP                  4        V P                  V4       R# )zW
L{StrictPushProducer} is paused if C{pauseProducing} is called on a
resumed producer.
N)rm   rS   ry   rc   s   & r   Útest_resumeThenPauseÚ,StrictPushProducerTests.test_resumeThenPauseÕ   ó)   € ð
 —=‘=“?ˆØ×ÑÔ!Ø×Ñ˜(Ö#r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   Þ   s   € ÷ @ñ @ tñ @r   c                óf   € V P                  4       pV P                  \        VP                  4       R# )z]
L{StrictPushProducer.resumeProducing} raises L{ValueError} if called on a
resumed producer.
N)rm   r�   rK   rW   rc   s   & r   Útest_resumeThenResumeÚ-StrictPushProducerTests.test_resumeThenResumeÞ   ó%   € ð
 —=‘=“?ˆØ×Ñœ* h×&>Ñ&>Ö?r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   æ   s   € ÷ %ñ %˜4ñ %r   c                óh   € V P                  4       pVP                  4        V P                  V4       R# )zV
L{StrictPushProducer} is stopped if C{stopProducing} is called in the
initial state.
N)r_   rM   rt   rc   s   & r   Ú	test_stopÚ!StrictPushProducerTests.test_stopæ   rœ   r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   ï   s   € ÷ $ñ $˜Dñ $r   c                óh   € V P                  4       pVP                  4        V P                  V4       R# )zV
L{StrictPushProducer} is paused if C{pauseProducing} is called in the
initial state.
N)r_   rS   ry   rc   s   & r   Ú
test_pauseÚ"StrictPushProducerTests.test_pauseï   r¡   r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r]   ø   s   € ÷ @ñ @˜Tñ @r   c                óf   € V P                  4       pV P                  \        VP                  4       R# )zb
L{StrictPushProducer} raises L{ValueError} if C{resumeProducing} is called
in the initial state.
N)r_   r�   rK   rW   rc   s   & r   Útest_resumeÚ#StrictPushProducerTests.test_resumeø   r¦   r   r   N)r<   r=   r>   r?   r@   r_   re   ri   rm   rt   ry   r}   r‚   r†   rŠ   rŽ   r’   r–   rš   rŸ   r¤   r©   r­   r±   rA   r   r   r   rZ   rZ   ]   sq   † ñõ$õõõõ5õ4õ5õEõFõGõ%õ?õ%õ%õ$õ@õ%õ$÷@ñ @r   rZ   c                  óJ   € ] tR tRtRtR R ltR R ltR R ltR	 R
 ltRt	R# )ÚIOPumpTestsi  z
Tests for L{IOPump}.
c               ó    € V ^8„  d   QhRRRR/# )r   ÚmodezLiteral['server', 'client']r   r   r   )r   s   "r   r   ÚIOPumpTests.__annotate__  s   € ÷ !5ñ !5Ð+Fð !5È4ñ !5r   c                ó.  € \        4       p\        VRR7      p\        4       p\        VRR7      p\        VVVVRR7      p\        4       pRVRV/V,          pVP	                  VRR7       VP                  4        V P                  RVP                  4       R	# )
aŒ  
Connect a couple protocol/transport pairs to an L{IOPump} and then pump
it.  Verify that a streaming producer registered with one of the
transports does not receive invalid L{IPushProducer} method calls and
ends in the right state.

@param mode: C{u"server"} to test a producer registered with the
    server transport.  C{u"client"} to test a producer registered with
    the client transport.
T)ÚisServerF)ÚgreetÚserverÚclient)Ú	streamingrD   N)r   r   r   rC   ÚregisterProducerÚpumpr1   rJ   )	r$   r¶   ÚserverProtoÚserverTransportÚclientProtoÚclientTransportr¿   rd   Úvictims	   &&       r   Ú_testStreamingProducerÚ"IOPumpTests._testStreamingProducer  sš   € ô “jˆÜ'¨¸dÔCˆä“jˆÜ'¨¸eÔDˆäØØØØØô
ˆô &Ó'ˆà�oØ�oð
ð õˆð 	×Ñ °DÐÔ9à�	‰	ŒØ×Ñ˜ H§O¡OÖ4r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r·   )  ó   € ÷ 3ñ 3¨dñ 3r   c                ó*   € V P                  RR7       R# )z
L{IOPump.pump} does not call C{resumeProducing} on a L{IPushProducer}
(stream producer) registered with the server transport.
r»   ©r¶   N©rÅ   rL   s   &r   Útest_serverStreamingProducerÚ(IOPumpTests.test_serverStreamingProducer)  ó   € ð
 	×#Ñ#¨Ð#Ö2r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r·   0  rÈ   r   c                ó*   € V P                  RR7       R# )z
L{IOPump.pump} does not call C{resumeProducing} on a L{IPushProducer}
(stream producer) registered with the client transport.
r¼   rÊ   NrË   rL   s   &r   Útest_clientStreamingProducerÚ(IOPumpTests.test_clientStreamingProducer0  rÎ   r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r·   7  s   € ÷ 
%ñ 
% 4ñ 
%r   c                óâ   a€ . o\        4       p\        \        \        VR7      w   r#VP                  ^ V3R l4       V P	                  S4       VP                  4        V P                  S4       R# )z5
L{IOPump.pump} advances time in the given L{Clock}.
)Úclockc                 ó&   <€ S P                  R 4      # )T)Úappend)Útime_passeds   €r   Ú<lambda>Ú/IOPumpTests.test_timeAdvances.<locals>.<lambda>>  s   ø€  ;×#5Ñ#5°dÔ#;r   N)r	   r   r   Ú	callLaterÚassertFalser¿   Ú
assertTrue)r$   rÕ   Ú_r¿   rØ   s   &   @r   Útest_timeAdvancesÚIOPumpTests.test_timeAdvances7  sU   ø€ ð ˆÜ“ˆÜ-¬h¼ÈÔN‰
ˆˆ1Ø�‰˜Ô;Ô<Ø×Ñ˜Ô%Ø�	‰	ŒØ�‰˜Ö$r   r   N)
r<   r=   r>   r?   r@   rÅ   rÌ   rÑ   rß   rA   r   r   r   r´   r´     s!   † ñõ!5õF3õ3÷
%ñ 
%r   r´   c                  ó2   € ] tR tRtRtR R ltR R ltRtR# )	ÚConnectionCompleterTestsiD  zf
L{ConnectionCompleter} can connect a connecting client and a listening
server in a L{MemoryReactor}.
c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   Ú%ConnectionCompleterTests.__annotate__J  s   € ÷ .ñ . 4ñ .r   c                ól   € \        \        4       4      pV P                  VP                  4       R4       R# )zd
When no connection for its reactor is pending,
L{ConnectionCompleter.succeedOnce} returns C{None}.
N)r   r
   ÚassertIsÚsucceedOnce)r$   Úccs   & r   Útest_noConnectionÚ*ConnectionCompleterTests.test_noConnectionJ  s%   € ô
 !¤£Ó1ˆØ�‰�b—n‘nÓ&¨Ö-r   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   rä   R  s   € ÷ 	8ñ 	8 Tñ 	8r   c                ó"  € \        4       pVP                  ^P\        P                  ! \        4      4       VP                  R^P\        P                  ! \        4      4       \        V4      pV P                  VP                  4       \        4       R# )zw
When a connection to a matched host and port is pending,
L{ConnectionCompleter} returns an L{IOPump} connecting them.
z	127.0.0.1N)r
   Ú	listenTCPr   ÚforProtocolr   Ú
connectTCPr   r   r    rç   r   )r$   Úmemrè   s   &  r   Útest_someConnectionÚ,ConnectionCompleterTests.test_someConnectionR  s`   € ô
 ‹oˆØ�‰�bœ'×-Ò-¬hÓ7Ô8Ø�‰�{ B¬×(AÒ(AÄ(Ó(KÔLÜ  Ó%ˆØ×Ñ˜bŸn™nÓ.´Ö7r   r   N)r<   r=   r>   r?   r@   ré   rñ   rA   r   r   r   râ   râ   D  s   † ñõ
.÷	8ñ 	8r   râ   N)r@   Ú
__future__r   Útypingr   Úzope.interfacer   Útwisted.internet.interfacesr   Útwisted.internet.protocolr   r   r   Útwisted.internet.taskr	   Útwisted.internet.testingr
   Útwisted.test.iosimr   r   r   r   r   Útwisted.trial.unittestr   r   rC   rZ   r´   râ   r   r   r   Ú<module>rü      sŠ   ðñõ #å å &å 5ß FÑ FÝ 'Ý 2÷õ õ ,ô&8˜ô &8ñR ˆ]Ó÷ ð  ó ð ô0a@˜hô a@ôH@%�(ô @%ôF8˜xö 8r   