ó
    ×›‘h„µ  ã                   ó8  • S r SSKrSSKrSSKrSSKJr  SSKJrJrJ	r	J
r
JrJrJr  SSKJrJr  SSKJr  SSKJr  SSKJr   SS	KJr  \r\(       a  \R4                  (       d  Sr " S
 S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rSr  " S S\RB                  5      r"\" \RF                  " \S5      (       + S5       " S S\5      5       r$\" \RJ                  " \S5      (       + S5       " S S\5      5       r& " S S\RN                  5      r( " S S \RR                  5      r* " S! S"\5      r+ " S# S$5      r, " S% S&\RZ                  5      r. " S' S(\,5      r/ " S) S*\5      r0 " S+ S,\5      r1 " S- S.\5      r2g! \ a    Sr GNNf = f)/zB
Tests for lots of functionality provided by L{twisted.internet}.
é    N)ÚskipIf)ÚabstractÚbaseÚdeferÚerrorÚ
interfacesÚprotocolÚreactor)ÚDeferredÚpassthru)Ú	Connector)Úutil)ÚTestCase)Ússlc                   ó–   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)ÚThreePhaseEventTestsé   zI
Tests for the private implementation helpers for system event triggers.
c                 óf   • S U l         [        5       U l        [        R                  " 5       U l        g)zB
Create a trigger, an argument, and an event to be used by tests.
c                 ó   • g ©N© )Úxs    Ú^C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/test/test_internet.pyÚ<lambda>Ú,ThreePhaseEventTests.setUp.<locals>.<lambda>(   s   €  ó    N)ÚtriggerÚobjectÚargr   Ú_ThreePhaseEventÚevent©Úselfs    r   ÚsetUpÚThreePhaseEventTests.setUp$   s$   € ñ &ˆŒÜ“8ˆŒÜ×*Ò*Ó,ˆ�
r   c                 ó†   • U R                  [        U R                  R                  SU R                  U R
                  5        g)z\
L{_ThreePhaseEvent.addTrigger} should raise L{KeyError} when called
with an invalid phase.
ÚxxxN)ÚassertRaisesÚKeyErrorr!   Ú
addTriggerr   r   r"   s    r   Útest_addInvalidPhaseÚ)ThreePhaseEventTests.test_addInvalidPhase,   s/   € ð
 	×ÑÜ�d—j‘j×+Ñ+¨U°D·L±LÀ$Ç(Á(õ	
r   c                 óä   • U R                   R                  SU R                  U R                  5        U R	                  U R                   R
                  U R                  U R                  40 4/5        g)z¡
L{_ThreePhaseEvent.addTrigger} should accept C{'before'} as a phase, a
callable, and some arguments and add the callable with the arguments to
the before list.
ÚbeforeN)r!   r*   r   r   ÚassertEqualr.   r"   s    r   Útest_addBeforeTriggerÚ*ThreePhaseEventTests.test_addBeforeTrigger5   óP   € ð 	�
‰
×Ñ˜h¨¯©°d·h±hÔ?Ø×Ñ˜Ÿ™×*Ñ*¨d¯l©l¸T¿X¹X¸KÈÐ-LÐ,MÕNr   c                 óä   • U R                   R                  SU R                  U R                  5        U R	                  U R                   R
                  U R                  U R                  40 4/5        g)z¡
L{_ThreePhaseEvent.addTrigger} should accept C{'during'} as a phase, a
callable, and some arguments and add the callable with the arguments to
the during list.
ÚduringN)r!   r*   r   r   r/   r4   r"   s    r   Útest_addDuringTriggerÚ*ThreePhaseEventTests.test_addDuringTrigger>   r2   r   c                 óä   • U R                   R                  SU R                  U R                  5        U R	                  U R                   R
                  U R                  U R                  40 4/5        g)zŸ
L{_ThreePhaseEvent.addTrigger} should accept C{'after'} as a phase, a
callable, and some arguments and add the callable with the arguments to
the after list.
ÚafterN)r!   r*   r   r   r/   r8   r"   s    r   Útest_addAfterTriggerÚ)ThreePhaseEventTests.test_addAfterTriggerG   sP   € ð 	�
‰
×Ñ˜g t§|¡|°T·X±XÔ>Ø×Ñ˜Ÿ™×)Ñ)¨T¯\©\¸D¿H¹H¸;ÈÐ,KÐ+LÕMr   c                 óè   • U R                   R                  SU R                  U R                  5      nU R                   R	                  U5        U R                  U R                   R                  / 5        g)z›
L{_ThreePhaseEvent.removeTrigger} should accept an opaque object
previously returned by L{_ThreePhaseEvent.addTrigger} and remove the
associated trigger.
r.   N)r!   r*   r   r   ÚremoveTriggerr/   r.   ©r#   Úhandles     r   Útest_removeTriggerÚ'ThreePhaseEventTests.test_removeTriggerP   sP   € ð —‘×&Ñ& x°·±¸t¿x¹xÓHˆØ�
‰
× Ñ  Ô(Ø×Ñ˜Ÿ™×*Ñ*¨BÕ/r   c                 ój   • U R                  [        U R                  R                  [	        5       5        g)zŽ
L{_ThreePhaseEvent.removeTrigger} should raise L{ValueError} when given
an object not previously returned by L{_ThreePhaseEvent.addTrigger}.
N)r(   Ú
ValueErrorr!   r<   r   r"   s    r   Útest_removeNonexistentTriggerÚ2ThreePhaseEventTests.test_removeNonexistentTriggerZ   s"   € ð
 	×Ñœ* d§j¡j×&>Ñ&>ÄÃÕIr   c                 óò   • U R                   R                  SU R                  U R                  5      nU R                   R	                  U5        U R                  [        U R                   R                  U5        g)z–
L{_ThreePhaseEvent.removeTrigger} should raise L{ValueError} the second
time it is called with an object returned by
L{_ThreePhaseEvent.addTrigger}.
r.   N)r!   r*   r   r   r<   r(   rB   r=   s     r   Útest_removeRemovedTriggerÚ.ThreePhaseEventTests.test_removeRemovedTriggera   sR   € ð —‘×&Ñ& x°·±¸t¿x¹xÓHˆØ�
‰
× Ñ  Ô(Ø×Ñœ* d§j¡j×&>Ñ&>ÀÕGr   c                 óŒ   • U R                  [        U R                  R                  SU R                  U R
                  40 45        g)z«
L{_ThreePhaseEvent.removeTrigger} should raise L{ValueError} if it is
given a trigger handle which resembles a valid trigger handle aside
from its phase being incorrect.
r'   N)r(   r)   r!   r<   r   r   r"   s    r   Útest_removeAlmostValidTriggerÚ2ThreePhaseEventTests.test_removeAlmostValidTriggerk   s7   € ð 	×ÑÜ�d—j‘j×.Ñ.°¸¿¹ÀtÇxÁxÀkÐSUÐ0Võ	
r   c                 ó\  • / nU R                   R                  SUR                  S5        U R                   R                  SUR                  S5        U R                   R                  SUR                  S5        U R                   R                  SUR                  S5        U R                   R                  SUR                  S5        U R                   R                  SUR                  S	5        U R                  U/ 5        U R                   R	                  5         U R                  U/ S
Q5        g)zl
L{_ThreePhaseEvent.fireEvent} should call I{before}, I{during}, and
I{after} phase triggers in that order.
r8   ©Úfirstr8   r4   ©rM   r4   r.   ©rM   r.   ©Úsecondr.   ©rQ   r4   ©rQ   r8   )rO   rP   rN   rR   rL   rS   N)r!   r*   Úappendr/   Ú	fireEvent©r#   Úeventss     r   Útest_fireEventÚ#ThreePhaseEventTests.test_fireEventu   sá   € ð
 ˆØ�
‰
×Ñ˜g v§}¡}Ð6HÔIØ�
‰
×Ñ˜h¨¯©Ð7JÔKØ�
‰
×Ñ˜h¨¯©Ð7JÔKØ�
‰
×Ñ˜h¨¯©Ð7KÔLØ�
‰
×Ñ˜h¨¯©Ð7KÔLØ�
‰
×Ñ˜g v§}¡}Ð6IÔJà×Ñ˜ Ô$Ø�
‰
×ÑÔØ×ÑØòõ
	
r   c                 óÀ  ^• / n[        5       mU R                  R                  SU4S j5        U R                  R                  SUR                  S5        U R                  R                  SUR                  S5        U R	                  U/ 5        U R                  R                  5         U R	                  U/ 5        TR                  S5        U R	                  USS/5        g)zŒ
L{_ThreePhaseEvent.fireEvent} should wait for any L{Deferred} returned
by a I{before} phase trigger before proceeding to I{during} events.
r.   c                  ó   >• T $ r   r   ©ÚbeforeResults   €r   r   Ú>ThreePhaseEventTests.test_asynchronousBefore.<locals>.<lambda>—   ó   ø€ ±r   r4   r8   N)r   r!   r*   rT   r/   rU   Úcallback)r#   rW   r]   s     @r   Útest_asynchronousBeforeÚ,ThreePhaseEventTests.test_asynchronousBefore�   s­   ø€ ð
 ˆÜ“zˆØ�
‰
×Ñ˜hÔ(<Ô=Ø�
‰
×Ñ˜h¨¯©°xÔ@Ø�
‰
×Ñ˜g v§}¡}°gÔ>à×Ñ˜ Ô$Ø�
‰
×ÑÔØ×Ñ˜ Ô$Ø×Ñ˜dÔ#Ø×Ñ˜ (¨GÐ!4Õ5r   c                 ó¼  ^• / n " S S[         5      mU4S jnU R                  R                  SU5        U R                  R                  SUR                  S5        U R                  R                  SUR                  S5        U R                  R	                  5         U R                  USS/5        U R                  T5      nU R                  [        U5      S5        g)zy
If a before-phase trigger raises a synchronous exception, it should be
logged and the remaining triggers should be run.
c                   ó   • \ rS rSrSrg)ÚHThreePhaseEventTests.test_beforeTriggerException.<locals>.DummyExceptioné¨   r   N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   r   r   ÚDummyExceptionre   ¨   ó   † Úr   rm   c                  ó   >• T " 5       er   r   ©rm   s   €r   ÚraisingTriggerÚHThreePhaseEventTests.test_beforeTriggerException.<locals>.raisingTrigger«   ó   ø€ Ù Ó"Ð"r   r.   r4   é   N©Ú	Exceptionr!   r*   rT   rU   r/   ÚflushLoggedErrorsÚlen©r#   rW   rq   Úerrorsrm   s       @r   Útest_beforeTriggerExceptionÚ0ThreePhaseEventTests.test_beforeTriggerException¡   s®   ø€ ð
 ˆô	œYô 	õ	#ð 	�
‰
×Ñ˜h¨Ô7Ø�
‰
×Ñ˜h¨¯©°xÔ@Ø�
‰
×Ñ˜h¨¯©°xÔ@Ø�
‰
×ÑÔØ×Ñ˜ (¨HÐ!5Ô6Ø×'Ñ'¨Ó7ˆØ×Ñœ˜V› aÕ(r   c                 ó¼  ^• / n " S S[         5      mU4S jnU R                  R                  SU5        U R                  R                  SUR                  S5        U R                  R                  SUR                  S5        U R                  R	                  5         U R                  USS/5        U R                  T5      nU R                  [        U5      S5        g)zy
If a during-phase trigger raises a synchronous exception, it should be
logged and the remaining triggers should be run.
c                   ó   • \ rS rSrSrg)ÚHThreePhaseEventTests.test_duringTriggerException.<locals>.DummyExceptioné½   r   Nrg   r   r   r   rm   r   ½   rn   r   rm   c                  ó   >• T " 5       er   r   rp   s   €r   rq   ÚHThreePhaseEventTests.test_duringTriggerException.<locals>.raisingTriggerÀ   rs   r   r4   r8   rt   Nru   ry   s       @r   Útest_duringTriggerExceptionÚ0ThreePhaseEventTests.test_duringTriggerException¶   s®   ø€ ð
 ˆô	œYô 	õ	#ð 	�
‰
×Ñ˜h¨Ô7Ø�
‰
×Ñ˜h¨¯©°xÔ@Ø�
‰
×Ñ˜g v§}¡}°gÔ>Ø�
‰
×ÑÔØ×Ñ˜ (¨GÐ!4Ô5Ø×'Ñ'¨Ó7ˆØ×Ñœ˜V› aÕ(r   c                 óv  ^ ^• / nUU 4S jnT R                   R                  SUR                  S5      mT R                   R                  SU5        T R                   R                  SUR                  S5        T R                  [        S[
        T R                   R                  5        T R                  USS/5        g)z|
If a before-phase trigger tries to remove another before-phase trigger
which has already run, a warning should be emitted.
c                  ó<   >• TR                   R                  T 5        g r   ©r!   r<   ©ÚbeforeHandler#   s   €€r   r<   ÚWThreePhaseEventTests.test_synchronousRemoveAlreadyExecutedBefore.<locals>.removeTriggerÒ   s   ø€ Ø�J‰J×$Ñ$ \Õ2r   r.   rO   rP   zdRemoving already-fired system event triggers will raise an exception in a future version of Twisted.N)r!   r*   rT   ÚassertWarnsÚDeprecationWarningÚ__file__rU   r/   )r#   rW   r<   r‰   s   `  @r   Ú+test_synchronousRemoveAlreadyExecutedBeforeÚ@ThreePhaseEventTests.test_synchronousRemoveAlreadyExecutedBeforeË   s¡   ù€ ð
 ˆö	3ð —z‘z×,Ñ,Ø�f—m‘mÐ%8ó
ˆð 	�
‰
×Ñ˜h¨Ô6Ø�
‰
×Ñ˜h¨¯©Ð7KÔLØ×ÑÜð8äØ�J‰J× Ñ ô	
ð 	×Ñ˜Ð"5Ð7KÐ!LÕMr   c                 óD  ^ ^• / nT R                   R                  SUU 4S j5        T R                   R                  SUR                  S5      mT R                   R                  SUR                  S5        T R                   R                  5         T R	                  US/5        g)z~
If a before-phase trigger removes another before-phase trigger which
has not yet run, the removed trigger should not be run.
r.   c                  ó:   >• TR                   R                  T 5      $ r   r‡   rˆ   s   €€r   r   ÚJThreePhaseEventTests.test_synchronousRemovePendingBefore.<locals>.<lambda>é   ó   ø€ °·
±
×0HÑ0HÈÔ0Vr   rO   rP   N©r!   r*   rT   rU   r/   )r#   rW   r‰   s   ` @r   Ú#test_synchronousRemovePendingBeforeÚ8ThreePhaseEventTests.test_synchronousRemovePendingBeforeã   ó€   ù€ ð
 ˆØ�
‰
×Ñ˜hÕ(VÔWØ—z‘z×,Ñ,Ø�f—m‘mÐ%8ó
ˆð 	�
‰
×Ñ˜h¨¯©Ð7KÔLØ�
‰
×ÑÔØ×Ñ˜Ð"6Ð!7Õ8r   c                 óD  ^ ^• / nT R                   R                  SUU 4S j5        T R                   R                  SUR                  S5      mT R                   R                  SUR                  S5        T R                   R                  5         T R	                  US/5        g)zg
If a before-phase trigger removes a during-phase trigger, the
during-phase trigger should not be run.
r.   c                  ó:   >• TR                   R                  T 5      $ r   r‡   ©ÚduringHandler#   s   €€r   r   ÚJThreePhaseEventTests.test_synchronousBeforeRemovesDuring.<locals>.<lambda>÷   r“   r   r4   r8   Nr”   ©r#   rW   r›   s   ` @r   Ú#test_synchronousBeforeRemovesDuringÚ8ThreePhaseEventTests.test_synchronousBeforeRemovesDuringñ   sw   ù€ ð
 ˆØ�
‰
×Ñ˜hÕ(VÔWØ—z‘z×,Ñ,¨X°v·}±}ÀhÓOˆØ�
‰
×Ñ˜g v§}¡}°gÔ>Ø�
‰
×ÑÔØ×Ñ˜ ' Õ+r   c                 ó¬  ^• / n[        5       mU R                  R                  SU4S j5        U R                  R                  SUR                  S5      nU R                  R                  SUR                  S5        U R                  R	                  5         U R                  R                  U5        TR                  S5        U R                  US/5        g)z¤
If a before-phase trigger returns a L{Deferred} and later removes a
during-phase trigger before the L{Deferred} fires, the during-phase
trigger should not be run.
r.   c                  ó   >• T $ r   r   r\   s   €r   r   ÚKThreePhaseEventTests.test_asynchronousBeforeRemovesDuring.<locals>.<lambda>  r_   r   r4   r8   N)r   r!   r*   rT   rU   r<   r`   r/   )r#   rW   r›   r]   s      @r   Ú$test_asynchronousBeforeRemovesDuringÚ9ThreePhaseEventTests.test_asynchronousBeforeRemovesDuringý   sž   ø€ ð ˆÜ“zˆØ�
‰
×Ñ˜hÔ(<Ô=Ø—z‘z×,Ñ,¨X°v·}±}ÀhÓOˆØ�
‰
×Ñ˜g v§}¡}°gÔ>Ø�
‰
×ÑÔØ�
‰
× Ñ  Ô.Ø×Ñ˜dÔ#Ø×Ñ˜ ' Õ+r   c                 ó&  ^ ^^• / mU4S jnT R                   R                  SU5        T R                   R                  SUU 4S j5        T R                   R                  SU5      mT R                   R                  5         T R                  TS/5        g)zß
If a before-phase trigger removes a during-phase trigger which is
identical to an already-executed before-phase trigger aside from their
phases, no warning should be emitted and the during-phase trigger
should not be run.
c                  ó(   >• T R                  S5        g )Nr   ©rT   ©rW   s   €r   r   Ú]ThreePhaseEventTests.test_synchronousBeforeRemovesConspicuouslySimilarDuring.<locals>.trigger  s   ø€ Ø�M‰M˜)Õ$r   r.   c                  ó:   >• TR                   R                  T 5      $ r   r‡   )ÚduringTriggerr#   s   €€r   r   Ú^ThreePhaseEventTests.test_synchronousBeforeRemovesConspicuouslySimilarDuring.<locals>.<lambda>  s   ø€ °·
±
×0HÑ0HÈÔ0Wr   r4   r   N)r!   r*   rU   r/   )r#   r   r«   rW   s   ` @@r   Ú7test_synchronousBeforeRemovesConspicuouslySimilarDuringÚLThreePhaseEventTests.test_synchronousBeforeRemovesConspicuouslySimilarDuring  sr   ú€ ð ˆõ	%ð 	�
‰
×Ñ˜h¨Ô0Ø�
‰
×Ñ˜hÕ(WÔXØŸ
™
×-Ñ-¨h¸Ó@ˆØ�
‰
×ÑÔØ×Ñ˜ ) Õ-r   c                 óD  ^ ^• / nT R                   R                  SUU 4S j5        T R                   R                  SUR                  S5      mT R                   R                  SUR                  S5        T R                   R                  5         T R	                  US/5        g)z~
If a during-phase trigger removes another during-phase trigger which
has not yet run, the removed trigger should not be run.
r4   c                  ó:   >• TR                   R                  T 5      $ r   r‡   rš   s   €€r   r   ÚJThreePhaseEventTests.test_synchronousRemovePendingDuring.<locals>.<lambda>%  r“   r   rN   rR   Nr”   r�   s   ` @r   Ú#test_synchronousRemovePendingDuringÚ8ThreePhaseEventTests.test_synchronousRemovePendingDuring  r—   r   c                 ó‚  • / nU R                   R                  SUR                  S5        U R                   R                  SUR                  S5        U R                   R                  SUR                  S5        U R                   R                  5         U R                   R                  5         U R	                  U/ SQ5        g)zU
A trigger should only be called on the first call to
L{_ThreePhaseEvent.fireEvent}.
r.   r4   r8   )r.   r4   r8   Nr”   rV   s     r   Útest_triggersRunOnceÚ)ThreePhaseEventTests.test_triggersRunOnce-  sˆ   € ð
 ˆØ�
‰
×Ñ˜h¨¯©°xÔ@Ø�
‰
×Ñ˜h¨¯©°xÔ@Ø�
‰
×Ñ˜g v§}¡}°gÔ>Ø�
‰
×ÑÔØ�
‰
×ÑÔØ×Ñ˜Ò!>Õ?r   c                 óü   ^ ^• / mUU 4S jnT R                   R                  STR                  S5        T R                   R                  SU5        T R                   R                  5         T R	                  TSS/5        g)zš
The temporary list L{_ThreePhaseEvent.finishedBefore} should be emptied
and the state reset to C{'BASE'} before the first during-phase trigger
executes.
c                  óÀ   >• T R                  S5        TR                  TR                  R                  / 5        TR                  TR                  R                  S5        g )Nr4   ÚBASE)rT   r/   r!   ÚfinishedBeforeÚstate)rW   r#   s   €€r   r«   ÚNThreePhaseEventTests.test_finishedBeforeTriggersCleared.<locals>.duringTriggerB  sC   ø€ Ø�M‰M˜(Ô#Ø×Ñ˜TŸZ™Z×6Ñ6¸Ô;Ø×Ñ˜TŸZ™Z×-Ñ-¨vÕ6r   r.   r4   Nr”   )r#   r«   rW   s   ` @r   Ú"test_finishedBeforeTriggersClearedÚ7ThreePhaseEventTests.test_finishedBeforeTriggersCleared:  sd   ù€ ð ˆö	7ð
 	�
‰
×Ñ˜h¨¯©°xÔ@Ø�
‰
×Ñ˜h¨Ô6Ø�
‰
×ÑÔØ×Ñ˜ (¨HÐ!5Õ6r   )r   r!   r   N)rh   ri   rj   rk   Ú__doc__r$   r+   r0   r5   r9   r?   rC   rF   rI   rX   ra   r{   rƒ   rŽ   r•   rž   r£   r­   r²   rµ   r½   rl   r   r   r   r   r      sw   † ñò-ò
òOòOòNò0òJòHò
ò
ò66ò")ò*)ò*Nò09ò
,ò,ò .ò$9ò@õ7r   r   c                   ó~   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rSrg)ÚSystemEventTestsiM  a  
Tests for the reactor's implementation of the C{fireSystemEvent},
C{addSystemEventTrigger}, and C{removeSystemEventTrigger} methods of the
L{IReactorCore} interface.

@ivar triggers: A list of the handles to triggers which have been added to
    the reactor.
c                 ó   • / U l         g)z9
Create an empty list in which to store trigger handles.
N©Útriggersr"   s    r   r$   ÚSystemEventTests.setUpW  s   € ð ˆ�r   c                 óÜ   • U R                   (       aE  U R                   R                  5       n [        R                  " U5        U R                   (       a  MD  gg! [        [
        4 a     N'f = f)z1
Remove all remaining triggers from the reactor.
N)rÄ   Úpopr
   ÚremoveSystemEventTriggerrB   r)   ©r#   r   s     r   ÚtearDownÚSystemEventTests.tearDown]  sT   € ð �m�mØ—m‘m×'Ñ'Ó)ˆGðÜ×0Ò0°Ô9ð �m�m‹møô ¤Ð)ó Ùðús   ­A ÁA+Á*A+c                 ój   • [         R                  " XU5      nU R                  R                  U5        U$ )zC
Add a trigger to the reactor and remember it in C{self.triggers}.
)r
   ÚaddSystemEventTriggerrÄ   rT   )r#   r!   ÚphaseÚfuncÚts        r   r*   ÚSystemEventTests.addTriggerh  s-   € ô ×)Ò)¨%¸Ó=ˆØ�‰×Ñ˜QÔØˆr   c                 óf   • [         R                  " U5        U R                  R                  U5        g)zL
Remove a trigger by its handle from the reactor and from
C{self.triggers}.
N)r
   rÈ   rÄ   ÚremoverÉ   s     r   r<   ÚSystemEventTests.removeTriggerp  s$   € ô
 	×(Ò(¨Ô1Ø�‰×Ñ˜WÕ%r   c                 ó´   ^• Sn/ mU4S jnU R                  XU5        U R                  T/ 5        [        R                  " U5        U R                  TS /5        g )NÚtestc                  ó(   >• T R                  S 5        g r   r§   r¨   s   €r   r   Ú<SystemEventTests._addSystemEventTriggerTest.<locals>.trigger|  ó   ø€ Ø�M‰M˜$Õr   ©r*   r/   r
   ÚfireSystemEvent)r#   rÎ   Ú	eventTyper   rW   s       @r   Ú_addSystemEventTriggerTestÚ+SystemEventTests._addSystemEventTriggerTestx  sR   ø€ Øˆ	Øˆõ	 ð 	�‰˜¨'Ô2Ø×Ñ˜ Ô$Ü×Ò 	Ô*Ø×Ñ˜ $ Õ(r   c                 ó&   • U R                  S5        g)z‰
L{IReactorCore.addSystemEventTrigger} should accept the C{'before'}
phase and not call the given object until the right event is fired.
r.   N©rÝ   r"   s    r   Útest_beforePhaseÚ!SystemEventTests.test_beforePhase„  ó   € ð
 	×'Ñ'¨Õ1r   c                 ó&   • U R                  S5        g)z‰
L{IReactorCore.addSystemEventTrigger} should accept the C{'during'}
phase and not call the given object until the right event is fired.
r4   Nrà   r"   s    r   Útest_duringPhaseÚ!SystemEventTests.test_duringPhase‹  rã   r   c                 ó&   • U R                  S5        g)zˆ
L{IReactorCore.addSystemEventTrigger} should accept the C{'after'}
phase and not call the given object until the right event is fired.
r8   Nrà   r"   s    r   Útest_afterPhaseÚ SystemEventTests.test_afterPhase’  s   € ð
 	×'Ñ'¨Õ0r   c                 óP   • SnU R                  [        U R                  SUS 5        g)zp
L{IReactorCore.addSystemEventTrigger} should reject phases other than
C{'before'}, C{'during'}, or C{'after'}.
rÖ   r'   c                  ó   • g r   r   r   r   r   r   Ú4SystemEventTests.test_unknownPhase.<locals>.<lambda>Ÿ  s   € Ètr   N)r(   r)   r*   )r#   rÜ   s     r   Útest_unknownPhaseÚ"SystemEventTests.test_unknownPhase™  s#   € ð
 ˆ	Ø×Ñœ( D§O¡O°U¸IÁ|ÕTr   c                 óæ   ^• Sn/ mU4S jnU4S jnU R                  SX5        U R                  SX5        U R                  T/ 5        [        R                  " U5        U R                  TSS/5        g)z”
L{IReactorCore.addSystemEventTrigger} should call triggers added to the
C{'before'} phase before it calls triggers added to the C{'during'}
phase.
rÖ   c                  ó(   >• T R                  S5        g ©Nr.   r§   r¨   s   €r   ÚbeforeTriggerÚASystemEventTests.test_beforePreceedsDuring.<locals>.beforeTriggerª  ó   ø€ Ø�M‰M˜(Õ#r   c                  ó(   >• T R                  S5        g ©Nr4   r§   r¨   s   €r   r«   ÚASystemEventTests.test_beforePreceedsDuring.<locals>.duringTrigger­  rô   r   r.   r4   NrÚ   )r#   rÜ   rò   r«   rW   s       @r   Útest_beforePreceedsDuringÚ*SystemEventTests.test_beforePreceedsDuring¡  sj   ø€ ð ˆ	Øˆõ	$õ	$ð 	�‰˜ )Ô;Ø�‰˜ )Ô;Ø×Ñ˜ Ô$Ü×Ò 	Ô*Ø×Ñ˜ (¨HÐ!5Õ6r   c                 óæ   ^• Sn/ mU4S jnU4S jnU R                  SX5        U R                  SX5        U R                  T/ 5        [        R                  " U5        U R                  TSS/5        g)z“
L{IReactorCore.addSystemEventTrigger} should call triggers added to the
C{'during'} phase before it calls triggers added to the C{'after'}
phase.
rÖ   c                  ó(   >• T R                  S5        g rö   r§   r¨   s   €r   r«   Ú@SystemEventTests.test_duringPreceedsAfter.<locals>.duringTrigger¿  rô   r   c                  ó(   >• T R                  S5        g )Nr8   r§   r¨   s   €r   ÚafterTriggerÚ?SystemEventTests.test_duringPreceedsAfter.<locals>.afterTriggerÂ  ó   ø€ Ø�M‰M˜'Õ"r   r4   r8   NrÚ   )r#   rÜ   r«   rþ   rW   s       @r   Útest_duringPreceedsAfterÚ)SystemEventTests.test_duringPreceedsAfter¶  sj   ø€ ð ˆ	Øˆõ	$õ	#ð 	�‰˜ )Ô;Ø�‰˜ Ô9Ø×Ñ˜ Ô$Ü×Ò 	Ô*Ø×Ñ˜ (¨GÐ!4Õ5r   c                 ó@  ^^• [        5       mSn/ mU4S jnU4S jnU R                  SX5        U R                  SX5        U R                  T/ 5        [        R                  " U5        U R                  T/ 5        TR                  S5        U R                  TS/5        g)z‘
If a trigger added to the C{'before'} phase of an event returns a
L{Deferred}, the C{'during'} phase should be delayed until it is called
back.
rÖ   c                  ó   >• T $ r   r   )ÚtriggerDeferreds   €r   rò   ÚBSystemEventTests.test_beforeReturnsDeferred.<locals>.beforeTriggerÕ  s	   ø€ Ø"Ð"r   c                  ó(   >• T R                  S5        g rö   r§   r¨   s   €r   r«   ÚBSystemEventTests.test_beforeReturnsDeferred.<locals>.duringTriggerØ  rô   r   r.   r4   N©r   r*   r/   r
   rÛ   r`   )r#   rÜ   rò   r«   rW   r  s       @@r   Útest_beforeReturnsDeferredÚ+SystemEventTests.test_beforeReturnsDeferredË  sŒ   ù€ ô #›*ˆØˆ	Øˆõ	#õ	$ð 	�‰˜ )Ô;Ø�‰˜ )Ô;Ø×Ñ˜ Ô$Ü×Ò 	Ô*Ø×Ñ˜ Ô$Ø× Ñ  Ô&Ø×Ñ˜ ( Õ,r   c                 óÌ  ^^^• [        5       m[        5       mSn/ mU4S jnU4S jnU4S jnU R                  SX5        U R                  SX5        U R                  SX5        U R                  T/ 5        [        R                  " U5        U R                  T/ 5        TR                  S5        U R                  T/ 5        TR                  S5        U R                  TS/5        g)z¢
If more than one trigger added to the C{'before'} phase of an event
return L{Deferred}s, the C{'during'} phase should be delayed until they
are all called back.
rÖ   c                  ó   >• T $ r   r   ©ÚfirstDeferreds   €r   ÚfirstBeforeTriggerÚNSystemEventTests.test_multipleBeforeReturnDeferred.<locals>.firstBeforeTriggerî  ó	   ø€ Ø Ð r   c                  ó   >• T $ r   r   )ÚsecondDeferreds   €r   ÚsecondBeforeTriggerÚOSystemEventTests.test_multipleBeforeReturnDeferred.<locals>.secondBeforeTriggerñ  s	   ø€ Ø!Ð!r   c                  ó(   >• T R                  S5        g rö   r§   r¨   s   €r   r«   ÚISystemEventTests.test_multipleBeforeReturnDeferred.<locals>.duringTriggerô  rô   r   r.   r4   Nr	  )r#   rÜ   r  r  r«   rW   r  r  s        @@@r   Ú!test_multipleBeforeReturnDeferredÚ2SystemEventTests.test_multipleBeforeReturnDeferredã  sÄ   ú€ ô !›
ˆÜ!›ˆØˆ	Øˆõ	!õ	"õ	$ð 	�‰˜ )Ô@Ø�‰˜ )ÔAØ�‰˜ )Ô;Ø×Ñ˜ Ô$Ü×Ò 	Ô*Ø×Ñ˜ Ô$Ø×Ñ˜tÔ$Ø×Ñ˜ Ô$Ø×Ñ Ô%Ø×Ñ˜ ( Õ,r   c                 ó¼  ^^^• Sn/ m[        5       m[        5       mU4S jnU4S jnUU4S jnU4S jnU R                  SX5        U R                  SX5        U R                  SX5        U R                  SX5        U R                  T/ 5        [        R                  " U5        U R                  TS/5        TR                  S5        U R                  TSS/5        g)	a1  
If a trigger added to the C{'before'} phase of an event calls back a
L{Deferred} returned by an earlier trigger in the C{'before'} phase of
the same event, the remaining C{'before'} triggers for that event
should be run and any further L{Deferred}s waited on before proceeding
to the C{'during'} events.
rÖ   c                  ó   >• T $ r   r   r  s   €r   r  ÚaSystemEventTests.test_subsequentBeforeTriggerFiresPriorBeforeDeferred.<locals>.firstBeforeTrigger  r  r   c                  ó(   >• T R                  S 5        g r   )r`   r  s   €r   r  ÚbSystemEventTests.test_subsequentBeforeTriggerFiresPriorBeforeDeferred.<locals>.secondBeforeTrigger  s   ø€ Ø×"Ñ" 4Õ(r   c                  ó*   >• T R                  S5        T$ rñ   r§   ©rW   r  s   €€r   ÚthirdBeforeTriggerÚaSystemEventTests.test_subsequentBeforeTriggerFiresPriorBeforeDeferred.<locals>.thirdBeforeTrigger  s   ø€ Ø�M‰M˜(Ô#Ø!Ð!r   c                  ó(   >• T R                  S5        g rö   r§   r¨   s   €r   r«   Ú\SystemEventTests.test_subsequentBeforeTriggerFiresPriorBeforeDeferred.<locals>.duringTrigger  rô   r   r.   r4   Nr	  )	r#   rÜ   r  r  r"  r«   rW   r  r  s	         @@@r   Ú4test_subsequentBeforeTriggerFiresPriorBeforeDeferredÚESystemEventTests.test_subsequentBeforeTriggerFiresPriorBeforeDeferred  s¾   ú€ ð ˆ	ØˆÜ ›
ˆÜ!›ˆõ	!õ	)ö	"õ	$ð 	�‰˜ )Ô@Ø�‰˜ )ÔAØ�‰˜ )Ô@Ø�‰˜ )Ô;Ø×Ñ˜ Ô$Ü×Ò 	Ô*Ø×Ñ˜ ( Ô,Ø×Ñ Ô%Ø×Ñ˜ (¨HÐ!5Õ6r   c                 ó  ^• Sn/ mU4S jnU4S jnU R                  SX5        U R                  U R                  SX5      5        U R                  T/ 5        [        R                  " U5        U R                  TS/5        g)zl
A trigger removed with L{IReactorCore.removeSystemEventTrigger} should
not be called when the event fires.
rÖ   c                  ó(   >• T R                  S5        g )NrM   r§   r¨   s   €r   r  ÚJSystemEventTests.test_removeSystemEventTrigger.<locals>.firstBeforeTrigger.  r   r   c                  ó(   >• T R                  S5        g )NrQ   r§   r¨   s   €r   r  ÚKSystemEventTests.test_removeSystemEventTrigger.<locals>.secondBeforeTrigger1  rô   r   r.   rM   N)r*   r<   r/   r
   rÛ   )r#   rÜ   r  r  rW   s       @r   Útest_removeSystemEventTriggerÚ.SystemEventTests.test_removeSystemEventTrigger&  sr   ø€ ð
 ˆ	Øˆõ	#õ	$ð 	�‰˜ )Ô@Ø×Ñ˜4Ÿ?™?¨8°YÓTÔUØ×Ñ˜ Ô$Ü×Ò 	Ô*Ø×Ñ˜ ' Õ+r   c           	      óH  • U R                  SSS 5      nU R                  U5        U R                  [        [        R
                  S5        U R                  [        [        R
                  U5        U R                  [        [        R
                  US   SUS   SS -   45        g)a  
Passing an object to L{IReactorCore.removeSystemEventTrigger} which was
not returned by a previous call to
L{IReactorCore.addSystemEventTrigger} or which has already been passed
to C{removeSystemEventTrigger} should result in L{TypeError},
L{KeyError}, or L{ValueError} being raised.
r4   rÖ   c                  ó   • g r   r   r   r   r   r   ÚKSystemEventTests.test_removeNonExistentSystemEventTrigger.<locals>.<lambda>B  s   € °dr   Nr   )r'   rt   )r*   r<   r(   Ú	TypeErrorr
   rÈ   rB   r)   )r#   Úbs     r   Ú(test_removeNonExistentSystemEventTriggerÚ9SystemEventTests.test_removeNonExistentSystemEventTrigger:  s‡   € ð �O‰O˜H f©lÓ;ˆØ×Ñ˜1ÔØ×Ñœ)¤W×%EÑ%EÀtÔLØ×Ñœ*¤g×&FÑ&FÈÔJØ×ÑÜ”g×6Ñ6¸¸1¹¸xÈ!ÈAÉ$ÈqÈrÈ(Ñ?RÐ8Sõ	
r   c                 ó`  ^^^	• / mSn[        5       mUU4S jnU4S jnSn[        5       m	UU	4S jnU4S jnU R                  SX5        U R                  SX5        U R                  SXE5        U R                  SXF5        U R                  T/ 5        [        R                  " U5        U R                  TS	/5        [        R                  " U5        U R                  TS	S
/5        TR                  S5        U R                  T/ SQ5        T	R                  S5        U R                  T/ SQ5        g)z¬
L{IReactorCore.fireSystemEvent} should behave the same way for a
particular system event regardless of whether Deferreds are being
waited on for a different system event.
zfirst-eventc                  ó*   >• T R                  S5        T$ )N©r.   rM   r§   )rW   r  s   €€r   ÚbeforeFirstEventÚQSystemEventTests.test_interactionBetweenDifferentEvents.<locals>.beforeFirstEventU  s   ø€ Ø�M‰MÐ-Ô.Ø Ð r   c                  ó(   >• T R                  S5        g )N©r8   rM   r§   r¨   s   €r   ÚafterFirstEventÚPSystemEventTests.test_interactionBetweenDifferentEvents.<locals>.afterFirstEventY  s   ø€ Ø�M‰MÐ,Õ-r   zsecond-eventc                  ó*   >• T R                  S5        T$ )N©r.   rQ   r§   r!  s   €€r   ÚbeforeSecondEventÚRSystemEventTests.test_interactionBetweenDifferentEvents.<locals>.beforeSecondEvent_  s   ø€ Ø�M‰MÐ.Ô/Ø!Ð!r   c                  ó(   >• T R                  S5        g )N©r8   rQ   r§   r¨   s   €r   ÚafterSecondEventÚQSystemEventTests.test_interactionBetweenDifferentEvents.<locals>.afterSecondEventc  s   ø€ Ø�M‰MÐ-Õ.r   r.   r8   r8  r@  N)r8  r@  r<  )r8  r@  r<  rD  r	  )
r#   Ú
firstEventr9  r=  ÚsecondEventrA  rE  rW   r  r  s
          @@@r   Ú&test_interactionBetweenDifferentEventsÚ7SystemEventTests.test_interactionBetweenDifferentEventsJ  s  ú€ ð ˆà"ˆ
Ü ›
ˆö	!õ	.ð %ˆÜ!›ˆö	"õ	/ð 	�‰˜ *Ô?Ø�‰˜ Ô=Ø�‰˜ +ÔAØ�‰˜ Ô?à×Ñ˜ Ô$ô 	×Ò 
Ô+Ø×Ñ˜Ð"5Ð!6Ô7ô 	×Ò Ô,Ø×Ñ˜Ð"5Ð7KÐ!LÔMð 	×Ñ˜tÔ$Ø×ÑØÒSô	
ð
 	×Ñ Ô%Ø×ÑØòõ	
r   rÃ   N)rh   ri   rj   rk   r¿   r$   rÊ   r*   r<   rÝ   rá   rå   rè   rí   rø   r  r
  r  r&  r-  r4  rI  rl   r   r   r   rÁ   rÁ   M  s^   † ñòò	òò&ò
)ò2ò2ò1òUò7ò*6ò*-ò0-ò>"7òH,ò(
õ >
r   rÁ   c                   ó`   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rSrg)Ú	TimeTestsi‹  z1
Tests for the IReactorTime part of the reactor.
c                 ó\   • [         R                  " 5       nU R                  X-
  U-   U5        g)aö  
L{twisted.internet.reactor.seconds} should return something
like a number.

1. This test specifically does not assert any relation to the
   "system time" as returned by L{time.time} or
   L{twisted.python.runtime.seconds}, because at some point we
   may find a better option for scheduling calls than
   wallclock-time.
2. This test *also* does not assert anything about the type of
   the result, because operations may not return ints or
   floats: For example, datetime-datetime == timedelta(0).
N)r
   Úsecondsr/   )r#   Únows     r   Útest_secondsÚTimeTests.test_seconds�  s&   € ô �oŠoÓˆØ×Ñ˜™ S™¨#Õ.r   c                 ó  • [         R                  nS [         l         [         R                  " SS 5      nU R                  UR	                  5       S5        U[         l        UR                  5         g! U[         l        f = f)z°
L{reactor.callLater<twisted.internet.interfaces.IReactorTime.callLater>}
should use the reactor's seconds factory
to produce the time at which the DelayedCall will be called.
c                  ó   • g©Néd   r   r   r   r   r   ÚITimeTests.test_callLaterUsesReactorSecondsInDelayedCall.<locals>.<lambda>¨  ó   €  #r   é   c                  ó   • g r   r   r   r   r   r   rV  ª  ó   € °r   éi   N)r
   rN  Ú	callLaterr/   ÚgetTimeÚcancel©r#   ÚosecondsÚcalls      r   Ú-test_callLaterUsesReactorSecondsInDelayedCallÚ7TimeTests.test_callLaterUsesReactorSecondsInDelayedCall¡  ó\   € ô —?‘?ˆÙ%ŒŒð	'Ü×$Ò$ Q©Ó5ˆDØ×Ñ˜TŸ\™\›^¨SÔ1à&ŒGŒOØ�‰�øð 'ŒG�Oúó   ž8A2 Á2A?c                 ó  • [         R                  nS [         l         [         R                  " SS 5      nU R                  UR                  5       S5        U[         l        UR	                  5         g! U[         l        f = f)z©
L{reactor.callLater<twisted.internet.interfaces.IReactorTime.callLater>}
should propagate its own seconds factory
to the DelayedCall to use as its own seconds factory.
c                  ó   • grT  r   r   r   r   r   ÚWTimeTests.test_callLaterUsesReactorSecondsAsDelayedCallSecondsFactory.<locals>.<lambda>·  rW  r   rX  c                  ó   • g r   r   r   r   r   r   rh  ¹  rZ  r   rU  N)r
   rN  r\  r/   r^  r_  s      r   Ú;test_callLaterUsesReactorSecondsAsDelayedCallSecondsFactoryÚETimeTests.test_callLaterUsesReactorSecondsAsDelayedCallSecondsFactory°  rd  re  c                 ó–   • [        5       n[        R                  " SUR                  S5        UR	                  U R
                  S5        U$ )zK
Test that a DelayedCall really calls the function it is
supposed to call.
r   N)r   r
   r\  r`   ÚaddCallbackr/   ©r#   Úds     r   Útest_callLaterÚTimeTests.test_callLater¿  s:   € ô
 ‹JˆÜ×Ò˜!˜QŸZ™Z¨Ô.Ø	�‰�d×&Ñ&¨Ô-Øˆr   c                 óì   • [         R                  " S[        [        5      nU R                  UR                  5        UR
                  nUR                  S5        U R                  UR
                  U5        g)zC
A L{DelayedCall} that is reset will be scheduled at the new time.
é   rt   N)r
   r\  r   Ú
addCleanupr^  ÚtimeÚresetÚassertNotEqual)r#   ra  ÚorigTimes      r   Útest_callLaterResetÚTimeTests.test_callLaterResetÉ  sP   € ô × Ò  ¤H¬hÓ7ˆØ�‰˜Ÿ™Ô$Ø—9‘9ˆØ�
‰
�1ŒØ×Ñ˜DŸI™I xÕ0r   c                 óÜ   ^ ^^• / mU4S jn[         R                  " SU5      nUR                  5         [        5       mUUU 4S jn[         R                  " S[         R                  SU5        T$ )z<
Test that when a DelayedCall is cancelled it does not run.
c                  ó(   >• T R                  S 5        g r   r§   )Úcalleds   €r   ÚfunctionÚ2TimeTests.test_cancelDelayedCall.<locals>.functionÙ  rÙ   r   r   c                  óŽ   >•  TR                  T / 5        TR                  S 5        g ! [         a    TR                  5          g f = fr   )r/   r`   ÚBaseExceptionÚerrback)r}  ro  r#   s   €€€r   ÚcheckÚ/TimeTests.test_cancelDelayedCall.<locals>.checkã  s@   ø€ ð!Ø× Ñ  ¨Ô,ð —
‘
˜4Õ øô !ó Ø—	‘	–ðús   ƒ' §AÁA)r
   r\  r^  r   )r#   r~  ra  rƒ  r}  ro  s   `   @@r   Útest_cancelDelayedCallÚ TimeTests.test_cancelDelayedCallÓ  s[   ú€ ð ˆõ	 ô × Ò   HÓ-ˆØ�‰Œô ‹Jˆ÷	!ô 	×Ò˜!œW×.Ñ.°°5Ô9Øˆr   c                 ó¨   • [         R                  " SS 5      nUR                  5         U R                  [        R
                  UR                  5        g)zg
Test that cancelling a DelayedCall which has already been cancelled
raises the appropriate exception.
r   c                  ó   • g r   r   r   r   r   r   Ú;TimeTests.test_cancelCancelledDelayedCall.<locals>.<lambda>ó  s   € ¨Dr   N)r
   r\  r^  r(   r   ÚAlreadyCancelled)r#   ra  s     r   Útest_cancelCancelledDelayedCallÚ)TimeTests.test_cancelCancelledDelayedCallî  s9   € ô
 × Ò  ¡LÓ1ˆØ�‰ŒØ×Ñœ%×0Ñ0°$·+±+Õ>r   c                 ó^   ^ ^^• [        5       mUUU 4S jn[        R                  " SU5      mT$ )z™
Test that cancelling a DelayedCall in the DelayedCall's function as
that function is being invoked by the DelayedCall raises the
appropriate exception.
c                  ó¾   >•  TR                  [        R                  T R                  5        TR	                  S 5        g ! [
         a    TR                  5          g f = fr   ©r(   r   ÚAlreadyCalledr^  r`   r�  r‚  ©ra  ro  r#   s   €€€r   ÚlaterÚ@TimeTests.test_cancelCalledDelayedCallSynchronous.<locals>.laterÿ  óJ   ø€ ð!Ø×!Ñ!¤%×"5Ñ"5°t·{±{ÔCð —
‘
˜4Õ øô !ó Ø—	‘	–ðúó   ƒ*? ¿AÁAr   ©r   r
   r\  )r#   r’  ra  ro  s   ` @@r   Ú'test_cancelCalledDelayedCallSynchronousÚ1TimeTests.test_cancelCalledDelayedCallSynchronous÷  s*   ú€ ô ‹Jˆ÷	!ô × Ò   EÓ*ˆØˆr   c                 ól   ^ ^^^• [        5       mUUU 4S jmU4S jn[        R                  " SU5      mT$ )zd
Test that cancelling a DelayedCall after it has run its function
raises the appropriate exception.
c                  ó¾   >•  TR                  [        R                  T R                  5        TR	                  S 5        g ! [
         a    TR                  5          g f = fr   r�  r‘  s   €€€r   rƒ  ÚATimeTests.test_cancelCalledDelayedCallAsynchronous.<locals>.check  r”  r•  c                  ó4   >• [         R                  " ST 5        g ©Nr   )r
   r\  )rƒ  s   €r   r’  ÚATimeTests.test_cancelCalledDelayedCallAsynchronous.<locals>.later  s   ø€ Ü×Ò˜a Õ'r   r   r–  )r#   r’  ra  rƒ  ro  s   ` @@@r   Ú(test_cancelCalledDelayedCallAsynchronousÚ2TimeTests.test_cancelCalledDelayedCallAsynchronous
  s/   û€ ô
 ‹Jˆ÷	!õ	(ô × Ò   EÓ*ˆØˆr   c                 óö   • [         R                  " SS 5      n U R                  UR                  5       [        R                  " 5       S-   -
  S:  5        UR                  5         g ! UR                  5         f = f)Né
   c                  ó   • g r   r   r   r   r   r   Ú-TimeTests.testCallLaterTime.<locals>.<lambda>   s   € ¨$r   rt   )r
   r\  Ú
assertTruer]  ru  r^  rn  s     r   ÚtestCallLaterTimeÚTimeTests.testCallLaterTime  sS   € Ü×Ò˜b¡,Ó/ˆð	Ø�O‰O˜AŸI™I›K¬4¯9ª9«;¸Ñ+;Ñ<¸qÑ@ÔAà�H‰H�JøˆA�H‰H�Jús   š;A& Á&A8c                 óþ  ^• [         R                  " SS SSS9m[        T5        TR                  S5        [        T5        TR	                  5         [        T5        [         R                  " SS /[        S5      Q7SSS	0S
4[         /06m[        T5        TR	                  5         [        T5        U4S jn[        5       R                  U5      n[         R                  " SUR                  S 5      m[        T5        U$ )Nr   c                 ó   • g r   r   )r   Úys     r   r   Ú:TimeTests.testDelayedCallStringification.<locals>.<lambda>)  s   € ¨tr   r   r¢  )rª  rX  c                  ó   • g r   r   r   r   r   r   r«  1  ó   € �tr   ÚhelloÚworldy              $@c                 ó   >• [        T5        g r   )Ústr)ÚignoredÚdcs    €r   Ú
calledBackÚ<TimeTests.testDelayedCallStringification.<locals>.calledBack7  s
   ø€ Ü��Gr   )	r
   r\  r±  rv  r^  Úranger   rm  r`   )r#   r´  ro  r³  s      @r   ÚtestDelayedCallStringificationÚ(TimeTests.testDelayedCallStringification&  sÓ   ø€ ô ×Ò˜qÑ"3°S¸BÑ?ˆÜˆBŒØ
�‰�ŒÜˆBŒØ
�	‰	ŒÜˆBŒä×ÒØ‰|ð
ÜFKÈBÃiò
Ø")¨7Ð!3°SÐ 9¼7ÐCñ
ˆô 	ˆBŒØ
�	‰	ŒÜˆBŒõ	ô ‹J×"Ñ" :Ó.ˆÜ×Ò˜q !§*¡*¨dÓ3ˆÜˆBŒØˆr   c           	      óê   • S n[         R                  " SS S0 S S U5      nU R                  UR                  5       S5        UR	                  S5        U R                  UR                  5       S5        g	)
zw
Test that the C{seconds} argument to DelayedCall gets used instead of
the default timing function, if it is not None.
c                  ó   • g)Nr¢  r   r   r   r   rN  Ú9TimeTests.testDelayedCallSecondsOverride.<locals>.secondsE  s   € Ør   rX  c                  ó   • g r   r   r   r   r   r   Ú:TimeTests.testDelayedCallSecondsOverride.<locals>.<lambda>I  r­  r   r   c                 ó   • g r   r   ©r³  s    r   r   r½  I  rZ  r   c                 ó   • g r   r   r¿  s    r   r   r½  I  s   € Àr   é   é   N)r   ÚDelayedCallr/   r]  rv  )r#   rN  r³  s      r   ÚtestDelayedCallSecondsOverrideÚ(TimeTests.testDelayedCallSecondsOverride?  sa   € ò	ô ×ÒØ‰|˜R ¡_±oÀwó
ˆð 	×Ñ˜Ÿ™› qÔ)Ø
�‰�ŒØ×Ñ˜Ÿ™› rÕ*r   r   N)rh   ri   rj   rk   r¿   rP  rb  rj  rp  ry  r…  r‹  r—  rŸ  r¦  r·  rÄ  rl   r   r   r   rL  rL  ‹  sC   † ñò/ò"òòò1òò6?òò&ò*òõ2+r   rL  c                   óv   • \ rS rSr\" \R                  " \S5      (       + S5      S 5       rS r	S r
S rS rS	rg)
Ú!CallFromThreadStopsAndWakeUpTestsiP  Nz-Nothing to wake up for without thread supportc                 óT   ^• [        5       mU4S jn[        R                  " U5        T$ )Nc                  ót   >• [         R                  " S5        [        R                  " T R                  S 5        g )Ngš™™™™™¹?)ru  Úsleepr
   ÚcallFromThreadr`   )ro  s   €r   ÚwakeÚ:CallFromThreadStopsAndWakeUpTests.testWakeUp.<locals>.wakeY  s"   ø€ Ü�JŠJ�sŒOä×"Ò" 1§:¡:¨tÕ4r   )r   r
   ÚcallInThread)r#   rÌ  ro  s     @r   Ú
testWakeUpÚ,CallFromThreadStopsAndWakeUpTests.testWakeUpQ  s&   ø€ ô ‹Jˆõ	5ô
 	×Ò˜TÔ"Øˆr   c                 ó   • SU l         g )NT©Ústoppedr"   s    r   Ú_stopCallFromThreadCallbackÚ=CallFromThreadStopsAndWakeUpTests._stopCallFromThreadCallbacka  s	   € Øˆ�r   c                 óˆ   • [         R                  " U R                  U5        [         R                  " SU R                  5        g r�  )r
   rË  Ú_callFromThreadCallback2r\  rÔ  rn  s     r   Ú_callFromThreadCallbackÚ9CallFromThreadStopsAndWakeUpTests._callFromThreadCallbackd  s.   € Ü×Ò˜t×<Ñ<¸aÔ@Ü×Ò˜!˜T×=Ñ=Õ>r   c                 óž   •  U R                  U R                  5        UR                  S 5        g ! [         a    UR	                  5          g f = fr   )r¥  rÓ  r`   r�  r‚  rn  s     r   r×  Ú:CallFromThreadStopsAndWakeUpTests._callFromThreadCallback2h  s?   € ð	Ø�O‰O˜DŸL™LÔ)ð
 �J‰J�tÕøô	 ó 	à�I‰IŽKð	ús   ‚/ ¯AÁAc                 ó€   • SU l         [        R                  " 5       n[        R                  " U R
                  U5        U$ )z„
Ensure that callFromThread from inside a callFromThread
callback doesn't sit in an infinite loop and lets other
things happen too.
F)rÓ  r   r   r
   rË  rØ  rn  s     r   ÚtestCallFromThreadStopsÚ9CallFromThreadStopsAndWakeUpTests.testCallFromThreadStopsq  s2   € ð ˆŒÜ�NŠNÓˆÜ×Ò˜t×;Ñ;¸QÔ?Øˆr   rÒ  )rh   ri   rj   rk   r   r   ÚIReactorThreadsr
   rÏ  rÔ  rØ  r×  rÝ  rl   r   r   r   rÇ  rÇ  P  sC   † ÙØ×&Ò& w°Ó5Ô5Ø7óñ
ó	ð
òò?òõ	r   rÇ  c                   óJ   • \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rSrg)ÚDelayedTestsi}  c                 ób   • SU l         SU l        0 U l        [        R                  " 5       U l        g r�  )ÚfinishedÚcounterÚtimersr   r   Údeferredr"   s    r   r$   ÚDelayedTests.setUp~  s%   € ØˆŒØˆŒØˆŒÜŸšÓ(ˆ�r   c                 óf   • U R                   R                  5        H  nUR                  5         M     g r   )rå  Úvaluesr^  )r#   rÐ   s     r   rÊ   ÚDelayedTests.tearDown„  s"   € Ø—‘×#Ñ#Ö%ˆAØ�H‰HŽJò &r   c                 ó  • U R                   R                  5       n[        [        R                  " 5       5      n/ nU H  nXB;  d  M
  UR                  U5        M     U(       a  SU l        U R                  US[        U5      -   5        g )Nrt   z7Should have been missing no calls, instead was missing )	rå  ré  Úlistr
   ÚgetDelayedCallsrT   rã  ÚassertFalseÚrepr)r#   Úl1Úl2Úmissingr³  s        r   ÚcheckTimersÚDelayedTests.checkTimersˆ  sw   € Ø�[‰[×ÑÓ!ˆÜ”'×)Ò)Ó+Ó,ˆð ˆÛˆBØ�|Ø—‘˜rÖ"ñ ö ØˆDŒMØ×ÑØðä�7‹mñõ	
r   c                 ó>   • U R                   U	 U R                  5         g r   )rå  ró  ©r#   Útags     r   r`   ÚDelayedTests.callback�  s   € Ø�K‰K˜ÐØ×ÑÕr   c                 ó^   • U R                  U5        U R                  SU R                   5        g )Né   )r`   ÚaddTimerrö  s     r   rm  ÚDelayedTests.addCallback¡  s    € Ø�‰�cÔØ�‰�b˜$Ÿ-™-Õ(r   c                 ój   • SU l         U R                  U5        U R                  R                  S 5        g )Nrt   )rã  r`   ræ  rö  s     r   ÚdoneÚDelayedTests.done¥  s'   € ØˆŒØ�‰�cÔØ�‰×Ñ˜tÕ$r   c                 óÄ   • [         R                  " US-  X R                  5      U R                  U R                  '   U =R                  S-  sl        U R	                  5         g )Nç{®Gáz„?rt   )r
   r\  rä  rå  ró  )r#   Úwhenr`   s      r   rû  ÚDelayedTests.addTimerª  sH   € Ü$+×$5Ò$5Ø�4‰K˜§<¡<ó%
ˆ�‰�D—L‘LÑ!ð 	�Š˜Ñ�Ø×ÑÕr   c                 ó‚  ^ • [        [        S5      (       d  g T R                  5         T R                  ST R                  5        T R                  ST R
                  5        T R                  ST R
                  5        T R                  nT R                  ST R
                  5        T R                  ST R                  5        T R                  ST R
                  5        T R                  U   R                  5         T R                  U	 T R                  5         T R                  R                  U 4S j5        T R                  $ )	Nrí  é#   é   é   é   é   é   c                 ó$   >• TR                  5       $ r   )ró  )r   r#   s    €r   r   Ú2DelayedTests.testGetDelayedCalls.<locals>.<lambda>Ä  s   ø€ ¨D×,<Ñ,<Ô,>r   )Úhasattrr
   ró  rû  rþ  r`   rä  rm  rå  r^  ræ  )r#   Úwhichs   ` r   ÚtestGetDelayedCallsÚ DelayedTests.testGetDelayedCalls±  sã   ø€ Ü”wÐ 1×2Ñ2Øð 	×ÑÔØ�‰�b˜$Ÿ)™)Ô$Ø�‰�b˜$Ÿ-™-Ô(Ø�‰�b˜$Ÿ-™-Ô(Ø—‘ˆØ�‰�b˜$Ÿ-™-Ô(Ø�‰�b˜$×*Ñ*Ô+Ø�‰�b˜$Ÿ-™-Ô(à�‰�EÑ×!Ñ!Ô#Ø�K‰K˜ÐØ×ÑÔà�‰×!Ñ!Ô">Ô?Ø�}‰}Ðr   c                 óø   ^ ^• [         R                  " ST R                  R                  S5      mT R	                  TR                  5       5        UU 4S jnT R                  R                  U5        T R                  $ )z=
L{IDelayedCall.active} returns False once the call has run.
r  Tc                 óF   >• TR                  TR                  5       5        U $ r   )rî  Úactive)ÚsuccessÚdcallr#   s    €€r   ÚcheckDeferredCallÚ3DelayedTests.test_active.<locals>.checkDeferredCallÎ  s   ø€ Ø×Ñ˜UŸ\™\›^Ô,ØˆNr   )r
   r\  ræ  r`   r¥  r  rm  )r#   r  r  s   ` @r   Útest_activeÚDelayedTests.test_activeÇ  sY   ù€ ô ×!Ò! $¨¯©×(>Ñ(>ÀÓEˆØ�‰˜Ÿ™›Ô'ö	ð 	�‰×!Ñ!Ð"3Ô4à�}‰}Ðr   )rä  ræ  rã  rå  N)rh   ri   rj   rk   r$   rÊ   ró  r`   rm  rþ  rû  r  r  rl   r   r   r   rá  rá  }  s/   † ò)òò
ò*ò)ò%ò
òõ,r   rá  aå  
import %(reactor)s
%(reactor)s.install()
from twisted.internet import reactor

class Foo:
    def __init__(self):
        reactor.callWhenRunning(self.start)
        self.timer = reactor.callLater(3, self.failed)
    def start(self):
        reactor.resolve('localhost').addBoth(self.done)
    def done(self, res):
        print('done', res)
        reactor.stop()
    def failed(self):
        print('failed')
        self.timer = None
        reactor.stop()
f = Foo()
reactor.run()
c                   ó2   • \ rS rSrS rS rS rS rS rSr	g)	ÚChildResolveProtocoliî  c                 ó   • Xl         g r   )ÚonCompletion)r#   r  s     r   Ú__init__ÚChildResolveProtocol.__init__ï  s   € Ø(Õr   c                 ó    • / U l         / U l        g r   )Úoutputr   r"   s    r   ÚconnectionMadeÚ#ChildResolveProtocol.connectionMadeò  s   € ØˆŒØˆ�
r   c                 ó:   • U R                   R                  U5        g r   )r!  rT   )r#   Úouts     r   ÚoutReceivedÚ ChildResolveProtocol.outReceivedö  s   € Ø�‰×Ñ˜3Õr   c                 ó:   • U R                   R                  U5        g r   )r   rT   )r#   Úerrs     r   ÚerrReceivedÚ ChildResolveProtocol.errReceivedù  s   € Ø�
‰
×Ñ˜#Õr   c                 ót   • U R                   R                  XR                  U R                  45        S U l         g r   )r  r`   r!  r   )r#   Úreasons     r   ÚprocessEndedÚ!ChildResolveProtocol.processEndedü  s+   € Ø×Ñ×"Ñ" F¯K©K¸¿¹Ð#DÔEØ ˆÕr   )r   r  r!  N)
rh   ri   rj   rk   r  r"  r&  r*  r.  rl   r   r   r   r  r  î  s   † ò)òò òõ!r   r  z8cannot run test: reactor doesn't support IReactorProcessc                   ó   • \ rS rSrS rSrg)ÚResolveTestsi  c                 óJ  ^ • [         R                  R                  T R                  5       5      n[	        US5       n[
        R                  nUR                  [        SU0-  5        S S S 5        [         R                  R                  5       n[         R                  R                  [        R                  5      US'   [        5       n[        U5      n[
        R                   " U[        R"                  SSU4U5        U 4S jnUR%                  U5        U$ ! , (       d  f       N´= f)NÚwr
   Ú
PYTHONPATHÚpythonz-uc           	      ó   >• U u  pnSR                  U5      nS[        R                  R                  S5      -   nX$:w  a@  TR	                  SR                  UR                  5       USR                  U5      5      5        g g )Nr   s   done 127.0.0.1Úasciiz’The child process failed to produce the desired results:
   Reason for termination was: {!r}
   Output stream was: {!r}
   Error stream was: {!r}
)ÚjoinÚosÚlinesepÚencodeÚfailÚformatÚgetErrorMessage)Úresultr-  r!  r   Úexpected_outputr#   s        €r   Ú
cbFinishedÚ1ResolveTests.testChildResolve.<locals>.cbFinished  ss   ø€ Ø&,Ñ#ˆV˜Uð —X‘X˜fÓ%ˆFØ/´"·*±*×2CÑ2CÀGÓ2LÑLˆOØÓ(Ø—	‘	ð6÷
 ‘f˜V×3Ñ3Ó5°v¸s¿x¹xÈ»ÓOõð )r   )r9  ÚpathÚabspathÚmktempÚopenr
   ri   ÚwriteÚresolve_helperÚenvironÚcopyÚpathsepr8  Úsysr   r  ÚspawnProcessÚ
executablerm  )r#   Ú
helperPathÚ
helperFileÚreactorNameÚenvÚhelperDeferredÚhelperProtorA  s   `       r   ÚtestChildResolveÚResolveTests.testChildResolve  sÖ   ø€ ô —W‘W—_‘_ T§[¡[£]Ó3ˆ
Ü�*˜cÔ" jä!×,Ñ,ˆKà×Ñœ^¨y¸+Ð.FÑFÔG÷	 #ô �j‰j�o‰oÓˆÜŸJ™JŸO™O¬C¯H©HÓ5ˆˆLÑä!›ˆÜ*¨>Ó:ˆä×ÒØœŸ™¨(°D¸*Ð)EÀsô	
õ	ð" 	×"Ñ" :Ô.ØÐ÷E #Õ"ús   »+DÄ
D"r   N)rh   ri   rj   rk   rU  rl   r   r   r   r1  r1    s   † õ
'r   r1  z&Nothing to test without thread supportc                   ó6   • \ rS rSrSrS rS rS rS rS r	Sr
g	)
ÚCallFromThreadTestsi0  z%
Task scheduling from threads tests.
c                 ó0   • SU l         [        5       U l        g r�  )rä  r   ræ  r"   s    r   r$   ÚCallFromThreadTests.setUp9  s   € ØˆŒÜ ›
ˆ�r   c                 ó0   • [         R                  " U0 UD6  g)z
Override in subclasses.
N)r
   rË  )r#   ÚargsÚkwargss      r   ÚscheduleÚCallFromThreadTests.schedule=  s   € ô 	×Ò Ð/¨Ó/r   c                 ón   ^ • U 4S jn[        S5       H  nT R                  U5        M     T R                  $ )zj
L{IReactorThreads.callFromThread} can be used to schedule a large
number of calls in the reactor thread.
c                  óˆ   >• T =R                   S-  sl         T R                   S:X  a  T R                  R                  S5        g g )Nrt   rU  T©rä  ræ  r`   r"   s   €r   ÚaddAndMaybeFinishÚVCallFromThreadTests.test_lotsOfThreadsAreScheduledCorrectly.<locals>.addAndMaybeFinishI  s4   ø€ Ø�LŠL˜AÑ�LØ�|‰|˜sÓ"Ø—‘×&Ñ& tÕ,ð #r   rU  )r¶  r^  ræ  )r#   rc  Úis   `  r   Ú'test_lotsOfThreadsAreScheduledCorrectlyÚ;CallFromThreadTests.test_lotsOfThreadsAreScheduledCorrectlyC  s1   ø€ õ	-ô
 �s–ˆAØ�M‰MÐ+Ö,ñ ð �}‰}Ðr   c                 óx  ^ ^• / mUU 4S jnT R                   R                  U5        T R                  TR                  S5        T R                  TR                  S5        T R                  TR                  S5        T R                  [        R
                  T R                   R                  S5        T R                   $ )z?
Callbacks should be invoked in the order they were scheduled.
c                 ó.   >• TR                  T/ SQ5        g )N)rt   rs  rÁ  )r/   )Ú_Úorderr#   s    €€r   rƒ  ÚECallFromThreadTests.test_threadsAreRunInScheduledOrder.<locals>.checkY  s   ø€ Ø×Ñ˜U¢IÕ.r   rt   rs  rÁ  N)ræ  rm  r^  rT   r
   rË  r`   )r#   rƒ  rk  s   ` @r   Ú"test_threadsAreRunInScheduledOrderÚ6CallFromThreadTests.test_threadsAreRunInScheduledOrderS  sƒ   ù€ ð ˆö	/ð 	�‰×!Ñ! %Ô(Ø�‰�e—l‘l AÔ&Ø�‰�e—l‘l AÔ&Ø�‰�e—l‘l AÔ&Ø�‰”g×,Ñ,¨d¯m©m×.DÑ.DÀdÔKà�}‰}Ðr   c                 ó‚   ^ • U 4S jnT R                  U5        T R                  T R                  S5        T R                  $ )zE
Scheduled tasks should not be run until the reactor starts running.
c                  óJ   >• ST l         T R                  R                  S5        g )Nrt   Trb  r"   s   €r   ÚincAndFinishÚUCallFromThreadTests.test_scheduledThreadsNotRunUntilReactorRuns.<locals>.incAndFinishi  s   ø€ ØˆDŒLØ�M‰M×"Ñ" 4Õ(r   r   )r^  r/   rä  ræ  )r#   rq  s   ` r   Ú+test_scheduledThreadsNotRunUntilReactorRunsÚ?CallFromThreadTests.test_scheduledThreadsNotRunUntilReactorRunsd  s6   ø€ õ
	)ð 	�‰�lÔ#ð 	×Ñ˜Ÿ™ qÔ)à�}‰}Ðr   )rä  ræ  N)rh   ri   rj   rk   r¿   r$   r^  rf  rm  rs  rl   r   r   r   rX  rX  0  s    † ñ
ò#ò0òò õ"r   rX  c                   ó   • \ rS rSrSrSrg)Ú
MyProtocoliu  z
Sample protocol.
r   N)rh   ri   rj   rk   r¿   rl   r   r   r   rv  rv  u  s   † ôr   rv  c                   ó   • \ rS rSrSr\rSrg)Ú	MyFactoryi{  z
Sample factory.
r   N)rh   ri   rj   rk   r¿   rv  r	   rl   r   r   r   rx  rx  {  s   † ñð ƒHr   rx  c                   ó   • \ rS rSrS rSrg)ÚProtocolTestsiƒ  c                 ó¨   • [        5       nUR                  S 5      nU R                  UR                  U5        U R	                  X!R
                  5        g r   )rx  ÚbuildProtocolr/   ÚfactoryÚassertIsInstancer	   )r#   r}  r	   s      r   ÚtestFactoryÚProtocolTests.testFactory„  sC   € Ü“+ˆØ×(Ñ(¨Ó.ˆØ×Ñ˜×)Ñ)¨7Ô3Ø×Ñ˜h×(8Ñ(8Õ9r   r   N)rh   ri   rj   rk   r  rl   r   r   r   rz  rz  ƒ  s   † õ:r   rz  c                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚDummyProduceri‹  ao  
Very uninteresting producer implementation used by tests to ensure the
right methods are called by the consumer with which it is registered.

@type events: C{list} of C{str}
@ivar events: The producer/consumer related events which have happened to
this producer.  Strings in this list may be C{'resume'}, C{'stop'}, or
C{'pause'}.  Elements are added as they occur.
c                 ó   • / U l         g r   r¨   r"   s    r   r  ÚDummyProducer.__init__–  s	   € Øˆ�r   c                 ó:   • U R                   R                  S5        g )NÚresume©rW   rT   r"   s    r   ÚresumeProducingÚDummyProducer.resumeProducing™  s   € Ø�‰×Ñ˜8Õ$r   c                 ó:   • U R                   R                  S5        g )NÚstopr‡  r"   s    r   ÚstopProducingÚDummyProducer.stopProducingœ  s   € Ø�‰×Ñ˜6Õ"r   c                 ó:   • U R                   R                  S5        g )NÚpauser‡  r"   s    r   ÚpauseProducingÚDummyProducer.pauseProducingŸ  s   € Ø�‰×Ñ˜7Õ#r   r¨   N)
rh   ri   rj   rk   r¿   r  rˆ  rŒ  r�  rl   r   r   r   r‚  r‚  ‹  s   † ñòò%ò#õ$r   r‚  c                   ó0   • \ rS rSrSrSrSrS rS r\r	Sr
g)	ÚSillyDescriptori£  zò
A descriptor whose data buffer gets filled very fast.

Useful for testing FileDescriptor's IConsumer interface, since
the data buffer fills as soon as at least four characters are
written to it, and gets emptied in a single doWrite() cycle.
rÁ  Tc                 ó   • [        U5      $ )z
Always write all data.
)rx   )r#   Údatas     r   ÚwriteSomeDataÚSillyDescriptor.writeSomeData¯  s   € ô �4‹yÐr   c                 ó   • g)z!
Do nothing: bypass the reactor.
Nr   r"   s    r   ÚstartWritingÚSillyDescriptor.startWritingµ  s   � r   r   N)rh   ri   rj   rk   r¿   Ú
bufferSizeÚ	connectedr–  r™  ÚstopWritingrl   r   r   r   r“  r“  £  s$   † ñð €JØ€Iòòð
 ƒKr   r“  c                   ó8   ^ • \ rS rSrSrU 4S jrU 4S jrSrU =r$ )ÚReentrantProduceri½  a°  
Similar to L{DummyProducer}, but with a resumeProducing method which calls
back into an L{IConsumer} method of the consumer against which it is
registered.

@ivar consumer: The consumer with which this producer has been or will
be registered.

@ivar methodName: The name of the method to call on the consumer inside
C{resumeProducing}.

@ivar methodArgs: The arguments to pass to the consumer method invoked in
C{resumeProducing}.
c                 óF   >• [         TU ]  5         Xl        X l        X0l        g r   )Úsuperr  ÚconsumerÚ
methodNameÚ
methodArgs)r#   r¢  r£  r¤  Ú	__class__s       €r   r  ÚReentrantProducer.__init__Í  s   ø€ Ü‰ÑÔØ ŒØ$ŒØ$�r   c                 ó|   >• [         TU ]  5         [        U R                  U R                  5      " U R
                  6   g r   )r¡  rˆ  Úgetattrr¢  r£  r¤  )r#   r¥  s    €r   rˆ  Ú!ReentrantProducer.resumeProducingÓ  s)   ø€ Ü‰ÑÔ!Ü�—‘˜tŸ™Ô/°·±ÒAr   )r¢  r¤  r£  )	rh   ri   rj   rk   r¿   r  rˆ  rl   Ú__classcell__)r¥  s   @r   rŸ  rŸ  ½  s   ø† ñõ%÷Bó Br   rŸ  c                   óH   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSrg)ÚProducerTestsiØ  z4
Test abstract.FileDescriptor's consumer interface.
c                 ó  • [         R                  " 5       nSUl        [        5       nUR	                  US5        U R                  UR                  S/5        U R                  [        UR                  [        5       S5        g)zŽ
Verify that registering a non-streaming producer invokes its
resumeProducing() method and that you can only register one producer
at a time.
rt   r   r†  N)	r   ÚFileDescriptorrœ  r‚  ÚregisterProducerr/   rW   r(   ÚRuntimeError©r#   ÚfdÚdps      r   Útest_doubleProducerÚ!ProducerTests.test_doubleProducerÝ  sb   € ô ×$Ò$Ó&ˆØˆŒÜ‹_ˆØ
×Ñ˜B Ô"Ø×Ñ˜Ÿ™ X JÔ/Ø×Ñœ,¨×(;Ñ(;¼]»_ÈaÕPr   c                 ó®   • [         R                  " 5       nSUl        [        5       nUR	                  US5        U R                  UR                  S/5        g)zt
Verify that registering a producer when the connection has already
been closed invokes its stopProducing() method.
rt   r   r‹  N)r   r®  Údisconnectedr‚  r¯  r/   rW   r±  s      r   Útest_unconnectedFileDescriptorÚ,ProducerTests.test_unconnectedFileDescriptorê  sF   € ô
 ×$Ò$Ó&ˆØˆŒÜ‹_ˆØ
×Ñ˜B Ô"Ø×Ñ˜Ÿ™ V HÕ-r   c                 ó2  • [        5       n[        5       nUR                  USS9  U R                  UR                  S/5        UR                  SS2	 US:X  a  UR                  / SQ5        OUR                  S5        U R                  UR                  / 5        g)zÔ
Pull consumers don't get their C{pauseProducing} method called if the
descriptor buffer fills up.

@param _methodName: Either 'write', or 'writeSequence', indicating
    which transport method to write data to.
F©Ú	streamingr†  NÚwriteSequence)ó   1ó   2ó   3ó   4s   1234)r“  r‚  r¯  r/   rW   r½  rG  )r#   r£  Ú
descriptorÚproducers       r   Ú_dontPausePullConsumerTestÚ(ProducerTests._dontPausePullConsumerTestõ  sƒ   € ô %Ó&ˆ
Ü “?ˆØ×#Ñ# H¸Ð#Ñ>Ø×Ñ˜Ÿ™¨8¨*Ô5Ø�O‰OšAÐð ˜Ó(Ø×$Ñ$Ò%=Õ>à×Ñ˜WÔ%à×Ñ˜Ÿ™¨"Õ-r   c                 ó$   • U R                  S5      $ )zÁ
Verify that FileDescriptor does not call producer.pauseProducing() on a
non-streaming pull producer in response to a L{IConsumer.write} call
which results in a full write buffer. Issue #2286.
rG  ©rÄ  r"   s    r   Ú!test_dontPausePullConsumerOnWriteÚ/ProducerTests.test_dontPausePullConsumerOnWrite  s   € ð ×.Ñ.¨wÓ7Ð7r   c                 ó$   • U R                  S5      $ )a  
Like L{test_dontPausePullConsumerOnWrite}, but for a call to
C{writeSequence} rather than L{IConsumer.write}.

C{writeSequence} is not part of L{IConsumer}, but
L{abstract.FileDescriptor} has supported consumery behavior in response
to calls to L{writeSequence} forever.
r½  rÇ  r"   s    r   Ú)test_dontPausePullConsumerOnWriteSequenceÚ7ProducerTests.test_dontPausePullConsumerOnWriteSequence  s   € ð ×.Ñ.¨Ó?Ð?r   c                 óº  • [        5       nUS:X  a  / SQnOSn[        X!U5      nUR                  USS9  [        X!5      " U5        U R	                  UR
                  S/5        UR
                  S S 2	 UR                  5         U R	                  UR
                  SS/5        UR
                  S S 2	 UR                  5         U R	                  UR
                  SS/5        g )Nr½  )ó   só   ps   ams   spamTr»  r�  r†  )r“  rŸ  r¯  r¨  r/   rW   ÚdoWrite)r#   r£  rÂ  r•  rÃ  s        r   Ú_reentrantStreamingProducerTestÚ-ProducerTests._reentrantStreamingProducerTest  sÈ   € Ü$Ó&ˆ
Ø˜Ó(Ú&‰DàˆDÜ$ Z¸TÓBˆØ×#Ñ# H¸Ð#Ñ=ô 	�
Ô'¨Ô-ð 	×Ñ˜Ÿ™¨7¨)Ô4Ø�O‰OšAÐð 	×ÑÔØ×Ñ˜Ÿ™¨8°WÐ*=Ô>Ø�O‰OšAÐð 	×ÑÔØ×Ñ˜Ÿ™¨8°WÐ*=Õ>r   c                 ó$   • U R                  S5      $ )zl
Verify that FileDescriptor tracks producer's paused state correctly.
Issue #811, fixed in revision r12857.
rG  ©rÑ  r"   s    r   Ú)test_reentrantStreamingProducerUsingWriteÚ7ProducerTests.test_reentrantStreamingProducerUsingWrite?  s   € ð
 ×3Ñ3°GÓ<Ð<r   c                 ó$   • U R                  S5      $ )zÿ
Like L{test_reentrantStreamingProducerUsingWrite}, but for calls to
C{writeSequence}.

C{writeSequence} is B{not} part of L{IConsumer}, however
C{abstract.FileDescriptor} has supported consumery behavior in response
to calls to C{writeSequence} forever.
r½  rÔ  r"   s    r   Ú1test_reentrantStreamingProducerUsingWriteSequenceÚ?ProducerTests.test_reentrantStreamingProducerUsingWriteSequenceF  s   € ð ×3Ñ3°OÓDÐDr   r   N)rh   ri   rj   rk   r¿   r´  r¸  rÄ  rÈ  rË  rÑ  rÕ  rØ  rl   r   r   r   r¬  r¬  Ø  s3   † ñòQò	.ò.ò.8ò	@ò?ò@=õ	Er   r¬  c                   ó  • \ rS rSr\" \R                  " \S5      (       + S5      S 5       r\" \R                  " \S5      (       + S5      S 5       r
\" \R                  " \S5      (       + S5      \" \(       + S5      \4S	 j5       5       rS
rg)ÚPortStringificationTestsiR  NzIReactorTCP is neededc                 ó  • [         R                  " S[        R                  " 5       5      nUR	                  5       R
                  nU R                  [        U5      R                  [        U5      5      SSX!4-  5        UR                  5       $ ©Nr   éÿÿÿÿú%d not found in %s)
r
   Ú	listenTCPr	   ÚServerFactoryÚgetHostÚportrw  r±  ÚfindÚstopListening©r#   ÚpÚportNos      r   ÚtestTCPÚ PortStringificationTests.testTCPS  sk   € ä×Ò˜a¤×!7Ò!7Ó!9Ó:ˆØ—‘“×!Ñ!ˆØ×ÑÜ�‹F�K‰Kœ˜F›Ó$ bÐ*>À&ÀÑ*Lô	
ð �‰Ó Ð r   zIReactorUDP is neededc                 ó  • [         R                  " S[        R                  " 5       5      nUR	                  5       R
                  nU R                  [        U5      R                  [        U5      5      SSX!4-  5        UR                  5       $ rÝ  )
r
   Ú	listenUDPr	   ÚDatagramProtocolrâ  rã  rw  r±  rä  rå  ræ  s      r   ÚtestUDPÚ PortStringificationTests.testUDP\  sk   € ä×Ò˜a¤×!:Ò!:Ó!<Ó=ˆØ—‘“×!Ñ!ˆØ×ÑÜ�‹F�K‰Kœ˜F›Ó$ bÐ*>À&ÀÑ*Lô	
ð �‰Ó Ð r   zIReactorSSL is neededzSSL support is missingc                 óp  • [         R                  " [        S5      n[        R                  " S[
        R                  " 5       UR                  X"5      5      nUR                  5       R                  nU R                  [        U5      R                  [        U5      5      SSXC4-  5        UR                  5       $ )Nz
server.pemr   rÞ  rß  )r   Úsibpathr�   r
   Ú	listenSSLr	   rá  ÚDefaultOpenSSLContextFactoryrâ  rã  rw  r±  rä  rå  )r#   r   Úpemrç  rè  s        r   ÚtestSSLÚ PortStringificationTests.testSSLe  s�   € ô �lŠlœ8 \Ó2ˆÜ×ÒØŒx×%Ò%Ó'¨×)IÑ)IÈ#Ó)Só
ˆð —‘“×!Ñ!ˆØ×ÑÜ�‹F�K‰Kœ˜F›Ó$ bÐ*>À&ÀÑ*Lô	
ð �‰Ó Ð r   r   )rh   ri   rj   rk   r   r   ÚIReactorTCPr
   ré  ÚIReactorUDPrî  ÚIReactorSSLr   rõ  rl   r   r   r   rÛ  rÛ  R  sœ   † Ù�
×&Ò& w°Ó5Ô5Ð7NÓOñ!ó Pð!ñ �
×&Ò& w°Ó5Ô5Ð7NÓOñ!ó Pð!ñ �
×&Ò& w°Ó5Ô5Ð7NÓOÙ�ŒGÐ-Ó.Øó 	!ó /ó Pó	!r   rÛ  c                   ó   • \ rS rSrS rSrg)ÚConnectorReprTestsis  c                 ó¸   • [        SS[        5       S[        5       5      nSnU[        U5      UR                  5       4-  nU R	                  [        U5      U5        g )NÚ	localhostiš  r   zA<twisted.internet.tcp.Connector instance at 0x%x disconnected %s>)r   r   ÚidÚgetDestinationr/   rï  )r#   ÚcÚexpects      r   Útest_tcp_reprÚ ConnectorReprTests.test_tcp_reprt  sM   € Ü�k 3¬«°!´V³XÓ>ˆØWˆØœ2˜a›5 !×"2Ñ"2Ó"4Ð5Ñ5ˆØ×Ñœ˜a› &Õ)r   r   N)rh   ri   rj   rk   r  rl   r   r   r   rû  rû  s  s   † õ*r   rû  )3r¿   r9  rL  ru  Úunittestr   Útwisted.internetr   r   r   r   r   r	   r
   Útwisted.internet.deferr   r   Útwisted.internet.tcpr   Útwisted.pythonr   Útwisted.trial.unittestr   r   Ú_sslÚImportErrorÚ	supportedr   rÁ   rL  rÇ  rá  rH  ÚProcessProtocolr  ÚIReactorProcessr1  rß  rX  ÚProtocolrv  ÚFactoryrx  rz  r‚  r®  r“  rŸ  r¬  rÛ  rû  r   r   r   Ú<module>r     sµ  ðñó
 
Û 
Û Ý ç X× XÑ Xß 5Ý *Ý Ý +ðÝ,ð €Cæˆs�}�}Ø
€Côk7˜8ô k7ô\	{
�xô {
ô|	B+�ô B+ôJ*¨ô *ôZW�8ô Wðt€ô.!˜8×3Ñ3ô !ñ& Ø×"Ò" 7¨DÓ1Ô1Ø>óô(�8ó (ó	ð(ñV Ø×"Ò" 7¨DÓ1Ô1Ø,óô>˜(ó >ó	ð>ôB�×"Ñ"ô ô�× Ñ ô ô:�Hô :÷$ñ $ô0�h×-Ñ-ô ô4B˜ô Bô6wE�Hô wEôt!˜xô !ôB*˜õ *øð{* ó Ø
ƒCðús   ÁF ÆFÆF