ó
    ×›‘h+ ã                  ó¤  • S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	r
SSKrSSKrSSKJrJrJrJr  SSKJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#  SSK$J%r%J&r&J'r'  SSK(J)r)  SSK*J+r+  SS	K,J-r-  SS
K.J/r/J0r0  SSK1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=  SSK>J?r?  SSK@JArA  SSKBJCrC  SSKDJErE  SSKFJ	r	      S>S jrG " S S\H5      rIS?S jrJ\!" S\HS9rK " S S5      rL " S S\	Rš                  5      rN " S S\	Rž                  \L5      rP " S S5      rQS@S jrR " S  S!\	Rž                  5      rS " S" S#\	Rž                  5      rT " S$ S%\	Rž                  5      rU " S& S'\	Rž                  5      rV " S( S)\	Rž                  5      rW " S* S+\	Rž                  5      rX " S, S-\	Rž                  \L5      rY " S. S/\	Rš                  5      rZSAS0 jr[ " S1 S2\	Rž                  5      r\ " S3 S4\	Rš                  5      r] " S5 S6\	Rš                  \L5      r^SBS7 jr_ " S8 S9\	Rš                  5      r` " S: S;\	Rš                  5      ra " S< S=\	Rž                  5      rbg)Cz+
Test cases for L{twisted.internet.defer}.
é    )ÚannotationsN)ÚAbstractEventLoopÚCancelledErrorÚFutureÚnew_event_loop)ÚAnyÚCallableÚ	CoroutineÚDictÚ	GeneratorÚListÚLiteralÚMappingÚNoReturnÚOptionalÚSetÚTupleÚTypeÚTypeVarÚUnionÚcast)Úassert_thatÚemptyÚequal_to)Úgiven)Úintegers)Úassert_type)ÚdeferÚreactor)Ú_TÚDeferredÚDeferredFilesystemLockÚDeferredListÚDeferredLockÚDeferredQueueÚDeferredSemaphoreÚFailureGroupÚ_DeferredListResultListTÚ_DeferredListSingleResultTÚensureDeferredÚrace)ÚClock)Úlog)Ú_PYPY©ÚFailure)Úunittestc                óJ   ^ • [         R                  " T 5      SU 4S jj5       nU$ )Nc                 ó@   >• T" U 0 UD6n[         R                  " U5      $ ©N)r!   ÚfromCoroutine)ÚargsÚkwargsÚcoroÚfs      €Ú[C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/test/test_defer.pyÚwrapperÚ!ensuringDeferred.<locals>.wrapperJ   s#   ø€ á�$Ð!˜&Ñ!ˆÜ×%Ò% dÓ+Ð+ó    )r6   Úobjectr7   r>   ÚreturnzDeferred[_T])Ú	functoolsÚwraps)r9   r;   s   ` r:   ÚensuringDeferredrB   G   s'   ø€ ô ‡_‚_�QÓö,ó ð,ð €Nr=   c                  ó   • \ rS rSrSrg)ÚGenericErroréR   © N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__rF   r=   r:   rD   rD   R   s   † Úr=   rD   c                ó&   • U R                  S5        g)z�
A fake L{Deferred} canceller which callbacks the L{Deferred}
with C{str} "Callback Result" when cancelling it.

@param deferred: The cancelled L{Deferred}.
úCallback ResultN©Úcallback©Údeferreds    r:   ÚfakeCallbackCancellerrS   V   s   € ð ×ÑÐ'Õ(r=   Ú_ExceptionT)Úboundc                  ó.   • \ rS rSrSr      SS jrSrg)ÚImmediateFailureMixinéc   z#
Add additional assertion methods.
c                ó&  • [        [        R                  U 5      n/ nUR                  UR                  5        UR                  [        U5      S5        UR                  US   R                  U5      5        [        [        US   R                  5      $ )zˆ
Assert that the given Deferred current result is a Failure with the
given exception.

@return: The exception instance in the Deferred.
é   r   )r   r1   ÚTestCaseÚ
addErrbackÚappendÚassertEqualÚlenÚ
assertTrueÚcheckrT   Úvalue)ÚselfrR   Ú	exceptionÚtestCaseÚfailuress        r:   ÚassertImmediateFailureÚ,ImmediateFailureMixin.assertImmediateFailureh   su   € ô œ×)Ñ)¨4Ó0ˆØ"$ˆØ×Ñ˜HŸO™OÔ,Ø×ÑœS ›]¨AÔ.Ø×Ñ˜H Q™K×-Ñ-¨iÓ8Ô9Ü”K ¨!¡×!2Ñ!2Ó3Ð3r=   rF   N)rR   úDeferred[Any]rd   zType[_ExceptionT]r?   rT   )rH   rI   rJ   rK   Ú__doc__rg   rL   rF   r=   r:   rW   rW   c   s$   † ñð4Ø%ð4Ø2Cð4à	÷4r=   rW   c                  ó6   • \ rS rSrSrSS jrSS jrSS jrSrg)	Ú	UtilTestséy   z
Tests for utility functions.
c                ó¢   • [        [        5       5      n[        R                  " U5      nU R	                  [        5        U R                  X5        g)z,
L{defer.logError} returns the given error.
N)r0   ÚRuntimeErrorr   ÚlogErrorÚflushLoggedErrorsÚassertIs)rc   ÚerrorÚresults      r:   Útest_logErrorReturnsErrorÚ#UtilTests.test_logErrorReturnsError~   s8   € ô œ›Ó'ˆÜ—’ Ó&ˆØ×Ñœ|Ô,à�‰�eÕ$r=   c                ó¤   • [        [        5       5      n[        R                  " U5        U R	                  [        5      nU R                  X!/5        g)z)
L{defer.logError} logs the given error.
N)r0   ro   r   rp   rq   r^   )rc   rs   Úerrorss      r:   Útest_logErrorLogsErrorÚ UtilTests.test_logErrorLogsErrorˆ   s<   € ô œ›Ó'ˆÜ�Š�uÔØ×'Ñ'¬Ó5ˆà×Ñ˜ Õ)r=   c                ó  ^• / mSU4S jjn[         R                  " U5        [        [        5       5      n[        R
                  " U5        U R                  [        5        U R                  TS   R                  S5      5        g)zB
The text logged by L{defer.logError} has no repr of the failure.
c                ó^   >• [         R                  " U 5      nUc   eTR                  U5        g r4   )r-   ÚtextFromEventDictr]   )Ú	eventDictÚtextÚoutputs     €r:   ÚemitÚ4UtilTests.test_logErrorLogsErrorNoRepr.<locals>.emit˜   s+   ø€ Ü×(Ò(¨Ó3ˆDØÑ#Ð#Ð#Ø�M‰M˜$Õr=   r   úUnhandled Error
Traceback N)r~   zDict[str, Any]r?   ÚNone)	r-   ÚaddObserverr0   ro   r   rp   rq   r`   Ú
startswith)rc   r�   rs   r€   s      @r:   Útest_logErrorLogsErrorNoReprÚ&UtilTests.test_logErrorLogsErrorNoRepr’   s_   ø€ ð ˆ÷	 ô
 	�Š˜Ôäœ›Ó'ˆÜ�Š�uÔØ×Ñœ|Ô,à�‰˜˜q™	×,Ñ,Ð-JÓKÕLr=   rF   N©r?   r„   )	rH   rI   rJ   rK   rj   ru   ry   r‡   rL   rF   r=   r:   rl   rl   y   s   † ñô%ô*÷Mr=   rl   c                  óô  • \ rS rSrS[S jrS\S jrS]S jrS^S jrS[S jrS[S jr	S[S jr
S[S	 jrS[S
 jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jrS[S jr S[S jr!S[S  jr"S[S! jr#S[S" jr$S[S# jr%S[S$ jr&S[S% jr'S[S& jr(S[S' jr)S[S( jr*S[S) jr+S[S* jr,S[S+ jr-S[S, jr.S[S- jr/S[S. jr0S[S/ jr1S[S0 jr2S[S1 jr3S[S2 jr4S[S3 jr5S[S4 jr6S[S5 jr7S[S6 jr8S[S7 jr9S[S8 jr:S[S9 jr;S[S: jr<S[S; jr=S[S< jr>S[S= jr?S[S> jr@S[S? jrAS[S@ jrBS[SA jrCS[SB jrDS[SC jrES[SD jrFS[SE jrGS[SF jrHS[SG jrIS[SH jrJS[SI jrKS[SJ jrLS[SK jrMS[SL jrNS[SM jrOS[SN jrPS[SO jrQS[SP jrRS[SQ jrSS[SR jrTS[SS jrU\VR®                  " \XST5      S[SU j5       rY\VR®                  " \XST5      S[SV j5       rZ\VR®                  " \XST5      S[SW j5       r[S[SX jr\SYr]gZ)_ÚDeferredTestsé¦   c                ó”   • S U l         S U l        S U l        U R                  [        R
                  [        R                  " 5       5        g r4   )ÚcallbackResultsÚcallback2ResultsÚerrbackResultsÚ
addCleanupr   ÚsetDebuggingÚgetDebugging©rc   s    r:   ÚsetUpÚDeferredTests.setUp§   sH   € ð ð 	Ôð
 ð 	Ôð
 ð 	Ôð
 	�‰œ×*Ñ*¬E×,>Ò,>Ó,@ÕAr=   c                ó   • X4U l         US   $ ©Nr   ©rŽ   ©rc   r6   r7   s      r:   Ú	_callbackÚDeferredTests._callbackµ   s   € Ø#˜|ˆÔØ�A‰wˆr=   c                ó   • X4U l         g r4   ©r�   rš   s      r:   Ú
_callback2ÚDeferredTests._callback2¹   s   € Ø $ ˆÕr=   c                ó   • X4U l         g r4   ©r�   rš   s      r:   Ú_errbackÚDeferredTests._errback¼   s   € Ø"˜lˆÕr=   c                óâ   • [        5       nUR                  U R                  5        UR                  S5        U R	                  U R
                  5        U R                  U R                  S0 45        g ©NÚhello©r§   ©r!   ÚaddCallbackr›   rP   ÚassertIsNoner�   r^   rŽ   ©rc   rR   s     r:   ÚtestCallbackWithoutArgsÚ%DeferredTests.testCallbackWithoutArgs¿   sX   € Ü"*£*ˆØ×Ñ˜TŸ^™^Ô,Ø×Ñ˜'Ô"Ø×Ñ˜$×-Ñ-Ô.Ø×Ñ˜×-Ñ-°
¸BÐ/?Õ@r=   c                óä   • [        5       nUR                  U R                  S5        UR                  S5        U R	                  U R
                  5        U R                  U R                  S0 45        g )NÚworldr§   )r§   r°   r©   r¬   s     r:   ÚtestCallbackWithArgsÚ"DeferredTests.testCallbackWithArgsÆ   s[   € Ü"*£*ˆØ×Ñ˜TŸ^™^¨WÔ5Ø×Ñ˜'Ô"Ø×Ñ˜$×-Ñ-Ô.Ø×Ñ˜×-Ñ-Ð0BÀBÐ/GÕHr=   c                óä   • [        5       nUR                  U R                  SS9  UR                  S5        U R	                  U R
                  5        U R                  U R                  SSS045        g )Nr°   )r°   r§   r¨   r©   r¬   s     r:   ÚtestCallbackWithKwArgsÚ$DeferredTests.testCallbackWithKwArgsÍ   sb   € Ü"*£*ˆØ×Ñ˜TŸ^™^°7ÐÑ;Ø×Ñ˜'Ô"Ø×Ñ˜$×-Ñ-Ô.Ø×Ñ˜×-Ñ-°
¸WÀgÐ<NÐ/OÕPr=   c                óT  • [        5       nUR                  U R                  5        UR                  U R                  5        UR	                  S5        U R                  U R                  5        U R                  U R                  S0 45        U R                  U R                  S0 45        g r¦   )
r!   rª   r›   rŸ   rP   r«   r�   r^   rŽ   r�   r¬   s     r:   ÚtestTwoCallbacksÚDeferredTests.testTwoCallbacksÔ   s…   € Ü"*£*ˆØ×Ñ˜TŸ^™^Ô,Ø×Ñ˜TŸ_™_Ô-Ø×Ñ˜'Ô"Ø×Ñ˜$×-Ñ-Ô.Ø×Ñ˜×-Ñ-°
¸BÐ/?Ô@Ø×Ñ˜×.Ñ.°¸RÐ0@ÕAr=   c                óî   • [        5       nUR                    U R                  5       nU R                  S[	        U5      5        U R                  [        US   S   5        U R                  SUS   S   5        g )NrZ   r   ÚcategoryzCtwisted.internet.defer.Deferred.callbacks was deprecated in TwistedÚmessage)r!   Ú	callbacksÚflushWarningsr^   r_   rr   ÚDeprecationWarningÚassertIn)rc   rR   Úwarningss      r:   Ú!test_callbacksAttributeDeprecatedÚ/DeferredTests.test_callbacksAttributeDeprecatedÝ   sg   € Ü"*£*ˆØ×Òà×%Ñ%Ó'ˆØ×Ñ˜œC ›MÔ*Ø�‰Ô(¨(°1©+°jÑ*AÔBØ�‰ØQØ�Q‰K˜	Ñ"õ	
r=   c                ó&  • [        S5      n[        5       nUR                  U R                  [	        [
        S[        4   S5      5        UR                  U5        UR                  U R                  5        U R                  U R                  5        U R                  c   eU R                  [        U R                  S   5      S5        U R                  U R                  S   S   R                  U5        U R                  U R                  S   0 5        g)zA
If given None for an errback, addCallbacks uses a pass-through.
Úoopsie.Nr   rZ   )rD   r!   ÚaddCallbacksr›   r   r	   r>   Úerrbackr\   r£   r«   rŽ   r�   r^   r_   rb   ©rc   rs   rR   s      r:   Útest_addCallbacksNoneErrbackÚ*DeferredTests.test_addCallbacksNoneErrbacké   sà   € ô ˜XÓ&ˆÜ#+£:ˆØ×Ñ˜dŸn™n¬d´8¸CÄ¸KÑ3HÈ$Ó.OÔPØ×Ñ˜ÔØ×Ñ˜DŸM™MÔ*Ø×Ñ˜$×.Ñ.Ô/Ø×"Ñ"Ñ.Ð.Ð.Ø×Ñœ˜T×0Ñ0°Ñ3Ó4°aÔ8Ø×Ñ˜×,Ñ,¨QÑ/°Ñ2×8Ñ8¸%Ô@Ø×Ñ˜×,Ñ,¨QÑ/°Õ4r=   c           
     ó`  • [        5       nUR                  U R                  U R                  [	        [
        [           S5      [	        [        [        [        4   S5      S0 5        UR                  S5        U R                  U R                  5        U R                  U R                  S0 45        g)zB
If given None as a callback args and kwargs, () and {} are used.
NrF   r§   r¨   )r!   rÅ   r›   r£   r   r   r>   r   ÚstrrP   r«   r�   r^   rŽ   r¬   s     r:   Ú!test_addCallbacksNoneCallbackArgsÚ/DeferredTests.test_addCallbacksNoneCallbackArgsø   s�   € ô #+£*ˆØ×ÑØ�N‰NØ�M‰MÜ””v‘ Ó%Ü”œœf˜Ñ% tÓ,ØØô	
ð 	×Ñ˜'Ô"Ø×Ñ˜$×-Ñ-Ô.Ø×Ñ˜×-Ñ-°
¸BÐ/?Õ@r=   c                ót  • [        S5      n[        5       nUR                  U R                  U R                  S0 [        [        [           S5      [        [        [        [        4   S5      5        UR                  U5        UR                  U R                  5        U R                  U R                  5        U R                  c   eU R                  [!        U R                  S   5      S5        U R                  U R                  S   S   R"                  U5        U R                  U R                  S   0 5        g)zA
If given None as a errback args and kwargs, () and {} are used.
rÄ   rF   Nr   rZ   )rD   r!   rÅ   r›   r£   r   r   r>   r   rË   rÆ   r\   r«   rŽ   r�   r^   r_   rb   rÇ   s      r:   Ú test_addCallbacksNoneErrbackArgsÚ.DeferredTests.test_addCallbacksNoneErrbackArgs	  s  € ô ˜XÓ&ˆÜ#+£:ˆØ×ÑØ�N‰NØ�M‰MØØÜ””v‘ Ó%Ü”œœf˜Ñ% tÓ,ô	
ð 	×Ñ˜ÔØ×Ñ˜DŸM™MÔ*Ø×Ñ˜$×.Ñ.Ô/Ø×"Ñ"Ñ.Ð.Ð.Ø×Ñœ˜T×0Ñ0°Ñ3Ó4°aÔ8Ø×Ñ˜×,Ñ,¨QÑ/°Ñ2×8Ñ8¸%Ô@Ø×Ñ˜×,Ñ,¨QÑ/°Õ4r=   c                ó|  • [         [        [        [        [        [
        4   4      n[        5       n[        5       n[        5       n[        X#U/5      n/ nU4S	S jjnS
S jnUR                  Xw5        UR                  S5        UR                  U5        UR                  [        S5      5        UR                  S5        U R                  US   US   S   [	        [        [
        US   S   5      R                  5      4US   /[         R"                  S4[         R$                  S4[         R"                  S4/5        g )Nc                ó&   • UR                  U 5        g r4   )Úextend©Ú
resultListrt   s     r:   ÚcbÚ*DeferredTests.testDeferredList.<locals>.cb(  s   € Ø�M‰M˜*Õ%r=   c                ó   • g r4   rF   ©Úerrs    r:   ÚcatchÚ-DeferredTests.testDeferredList.<locals>.catch+  ó   € Ør=   Ú1Ú2Ú3r   rZ   é   )rÕ   Ú
ResultListrt   râ   r?   r„   ©rÚ   r0   r?   r„   )r   r   Úboolr   rË   r0   r!   r#   rÅ   rP   r\   rÆ   rD   r^   r   rb   r   ÚSUCCESSÚFAILURE)	rc   râ   Údefr1Údefr2Údefr3Údlrt   rÖ   rÛ   s	            r:   ÚtestDeferredListÚDeferredTests.testDeferredList  s  € Üœ%¤¤e¬C´¨LÑ&9Ð 9Ñ:Ñ;ˆ
ä'›zˆÜ'›zˆÜ'›zˆÜ˜5¨Ð/Ó0ˆØˆà<Bö 	&ô	ð 	�‰˜ÔØ�‰�sÔØ×Ñ˜Ôð 	�‰”l 3Ó'Ô(Ø�‰�sÔØ×Ñà�q‘	à˜‘˜1‘œs¤4¬°¸±¸1±Ó#>×#DÑ#DÓEÐFØ�q‘	ð	ô �m‰m˜SÐ!¤E§M¡M°3Ð#7¼%¿-¹-ÈÐ9MÐNõ	
r=   c                óä   • / nU4     SS jjn[        / 5      nUR                  U5        U R                  U/ /5        / US S & [        / SS9nUR                  U5        U R                  U/ 5        g )Nc                ó&   • UR                  U 5        g r4   ©r]   rÔ   s     r:   rÖ   Ú/DeferredTests.testEmptyDeferredList.<locals>.cbF  s   € ð �M‰M˜*Õ%r=   T©ÚfireOnOneCallback)rÕ   z_DeferredListResultListT[None]rt   z$List[_DeferredListResultListT[None]]r?   r„   )r#   rÅ   r^   )rc   rt   rÖ   Údl1Údl2s        r:   ÚtestEmptyDeferredListÚ#DeferredTests.testEmptyDeferredListC  s‘   € Ø79ˆð <Bð	&Ø6ð	&à8ð	&ð õ	&ô 9EÀRÓ8HˆØ×Ñ˜ÔØ×Ñ˜ " Ô&àˆ‰qˆ	Ü:FØ $ñ;
ˆð 	×Ñ˜ÔØ×Ñ˜ Õ$r=   c                ó   • [        5       n[        5       n[        5       n[        XU/SS9n/ nUR                  UR                  5        S
S jnUR                  U5        UR	                  S5        U R                  U/ 5        UR                  [        S5      5        U R                  [        U5      S5        US   nU R                  [        UR                  [        R                  5      SUR                  < 35        UR                  nU R                  UR                  R                  [        5        U R                  UR                  R                  R                   S	5        U R                  UR"                  S5        g )NT©ÚfireOnOneErrbackc                ó   • g r4   rF   rÙ   s    r:   rÛ   Ú;DeferredTests.testDeferredListFireOnOneError.<locals>.catcha  rÝ   r=   rÞ   ú	from def2rZ   r   zFissubclass(aFailure.type, defer.FirstError) failed: failure's type is )rü   rã   )r!   r#   r\   r]   rP   r^   rÆ   rD   r_   r`   Ú
issubclassÚtyper   Ú
FirstErrorrb   Ú
subFailurer6   Úindex)	rc   rç   rè   ré   rê   rt   rÛ   ÚaFailureÚ
firstErrors	            r:   ÚtestDeferredListFireOnOneErrorÚ,DeferredTests.testDeferredListFireOnOneErrorW  s1  € Ü'›zˆÜ'›zˆÜ'›zˆÜ˜5¨Ð/À$ÑGˆØ "ˆØ
�‰�f—m‘mÔ$ô	ð 	×Ñ˜Ôð 	�‰�sÔØ×Ñ˜ Ô$ð 	�‰”l ;Ó/Ô0Ø×Ñœ˜V› aÔ(ð ˜!‘9ˆð 	�‰Ü�x—}‘}¤e×&6Ñ&6Ô7à&.§m£mð6ô	
ð —^‘^ˆ
ð 	×Ñ˜×.Ñ.×3Ñ3´\ÔBØ×Ñ˜×.Ñ.×4Ñ4×9Ñ9¸>ÔJØ×Ñ˜×)Ñ)¨1Õ-r=   c                óØ  • [        5       n[        U/5      n/ nUR                  UR                  5        / nUR	                  UR                  5        UR                  [        S5      5        U R                  SUS   R                  R                  S   5        U R                  S[        U5      5        US   S   nUc   eU R                  SUS   R                  R                  S   5        g )NÚBangr   rZ   )r!   r#   r\   r]   rª   rÆ   rD   r^   rb   r6   r_   ©rc   Úd1rê   Ú	errorTrapÚresultListsÚfirstResults         r:   Ú!testDeferredListDontConsumeErrorsÚ/DeferredTests.testDeferredListDontConsumeErrors€  sÍ   € Ü%›ZˆÜ˜2˜$Óˆà#%ˆ	Ø
�‰�i×&Ñ&Ô'à<>ˆØ
�‰�{×)Ñ)Ô*à
�
‰
”< Ó'Ô(Ø×Ñ˜ ¨1¡×!3Ñ!3×!8Ñ!8¸Ñ!;Ô<Ø×Ñ˜œC Ó,Ô-Ø! !‘n QÑ'ˆØÑ&Ð&Ð&Ø×Ñ˜ ¨Q¡×!5Ñ!5×!:Ñ!:¸1Ñ!=Õ>r=   c                ó¢  • [        5       n[        U/SS9n/ nUR                  UR                  5        / nUR	                  UR                  5        UR                  [        S5      5        U R                  / U5        U R                  S[        U5      5        US   S   nUc   eU R                  SUS   R                  R                  S   5        g )NT©ÚconsumeErrorsr  rZ   r   )r!   r#   r\   r]   rª   rÆ   rD   r^   r_   rb   r6   r  s         r:   ÚtestDeferredListConsumeErrorsÚ+DeferredTests.testDeferredListConsumeErrors‘  sº   € Ü%›ZˆÜ˜2˜$¨dÑ3ˆà#%ˆ	Ø
�‰�i×&Ñ&Ô'à<>ˆØ
�‰�{×)Ñ)Ô*à
�
‰
”< Ó'Ô(Ø×Ñ˜˜YÔ'Ø×Ñ˜œC Ó,Ô-Ø! !‘n QÑ'ˆØÑ&Ð&Ð&Ø×Ñ˜ ¨Q¡×!5Ñ!5×!:Ñ!:¸1Ñ!=Õ>r=   c                ó
  • [        5       n[        5       nUR                  [        S5      5        [        X/SS9n/ nUR	                  UR
                  5        U R                  S[        U5      5        UR	                  S 5        g )Nr  Trø   rZ   c                ó   • g r4   rF   ©Úes    r:   Ú<lambda>ÚWDeferredTests.testDeferredListFireOnOneErrorWithAlreadyFiredDeferreds.<locals>.<lambda>®  ó   €  r=   )r!   rÆ   rD   r#   r\   r]   r^   r_   ©rc   r	  Úd2rê   rt   s        r:   Ú7testDeferredListFireOnOneErrorWithAlreadyFiredDeferredsÚEDeferredTests.testDeferredListFireOnOneErrorWithAlreadyFiredDeferreds¢  sf   € ä%›ZˆÜ%›ZˆØ
�
‰
”< Ó'Ô(ô ˜2˜(°TÑ:ˆØ "ˆØ
�‰�f—m‘mÔ$Ø×Ñ˜œC ›KÔ(à
�‰‘nÕ%r=   c                ó.  • [        5       n[        5       nUR                  [        S5      5        UR                  S5        [	        X/5      n/ nUR                  UR                  5        U R                  S[        U5      5        UR                  S 5        g )Nr  rá   rZ   c                ó   • g r4   rF   r  s    r:   r  ÚIDeferredTests.testDeferredListWithAlreadyFiredDeferreds.<locals>.<lambda>¿  r  r=   )
r!   rÆ   rD   rP   r#   rª   r]   r^   r_   r\   r  s        r:   Ú)testDeferredListWithAlreadyFiredDeferredsÚ7DeferredTests.testDeferredListWithAlreadyFiredDeferreds°  so   € ä$›JˆÜ$›JˆØ
�
‰
”< Ó'Ô(Ø
�‰�AŒô ˜2˜(Ó#ˆà/1ˆØ
�‰�v—}‘}Ô%à×Ñ˜œC ›KÔ(à
�‰‘nÕ%r=   c                óä   • [        5       n[        5       n[        X/5      nUR                  5         U R                  U[        R
                  5        U R                  U[        R
                  5        g)zS
When cancelling an unfired L{DeferredList}, cancel every
L{Deferred} in the list.
N©r!   r#   ÚcancelÚfailureResultOfr   r   ©rc   ÚdeferredOneÚdeferredTwoÚdeferredLists       r:   Útest_cancelDeferredListÚ%DeferredTests.test_cancelDeferredListÁ  sW   € ô
 '/£jˆÜ&.£jˆÜ# [Ð$>Ó?ˆØ×ÑÔØ×Ñ˜[¬%×*>Ñ*>Ô?Ø×Ñ˜[¬%×*>Ñ*>Õ?r=   c                óÄ  • [        [        5      n[        5       n[        X/5      nUR                  5         U R	                  U[
        R                  5        U R                  U5      nU R                  US   S   5        U R                  US   S   S5        U R                  US   S   5        U R                  US   S   R                  [
        R                  5      5        g)zÄ
When cancelling an unfired L{DeferredList} without the
C{fireOnOneCallback} and C{fireOnOneErrback} flags set, the
L{DeferredList} will be callback with a C{list} of
(success, result) C{tuple}s.
r   rZ   rN   N)r!   rS   r#   r&  r'  r   r   ÚsuccessResultOfr`   r^   ÚassertFalsera   ©rc   r)  r*  r+  rt   s        r:   Útest_cancelDeferredListCallbackÚ-DeferredTests.test_cancelDeferredListCallbackÍ  s½   € ô &.Ô.CÓ%DˆÜ%-£ZˆÜ# [Ð$>Ó?ˆØ×ÑÔØ×Ñ˜[¬%×*>Ñ*>Ô?Ø×%Ñ% lÓ3ˆØ�‰˜˜q™	 !™Ô%Ø×Ñ˜ ™ 1™Ð'8Ô9Ø×Ñ˜ ™ 1™Ô&Ø�‰˜˜q™	 !™×*Ñ*¬5×+?Ñ+?Ó@ÕAr=   c                óâ   • [        5       n[        5       n[        X/SS9nUR                  5         U R                  U[        R
                  5        U R                  U[        R
                  5        g)zz
When cancelling an unfired L{DeferredList} with the flag
C{fireOnOneCallback} set, cancel every L{Deferred} in the list.
Trñ   Nr%  r(  s       r:   Ú,test_cancelDeferredListWithFireOnOneCallbackÚ:DeferredTests.test_cancelDeferredListWithFireOnOneCallbackß  sZ   € ô
 '/£jˆÜ&.£jˆÜ# [Ð$>ÐRVÑWˆØ×ÑÔØ×Ñ˜[¬%×*>Ñ*>Ô?Ø×Ñ˜[¬%×*>Ñ*>Õ?r=   c                óò   • [        [        5      n[        5       n[        X/SS9nUR                  5         U R	                  U[
        R                  5        U R                  U5      nU R                  US5        g)zì
When cancelling an unfired L{DeferredList} with the flag
C{fireOnOneCallback} set, if one of the L{Deferred} callbacks
in its canceller, the L{DeferredList} will callback with the
result and the index of the L{Deferred} in a C{tuple}.
Trñ   )rN   r   N)	r!   rS   r#   r&  r'  r   r   r/  r^   r1  s        r:   Ú?test_cancelDeferredListWithFireOnOneCallbackAndDeferredCallbackÚMDeferredTests.test_cancelDeferredListWithFireOnOneCallbackAndDeferredCallbackë  si   € ô &.Ô.CÓ%DˆÜ%-£ZˆÜ# [Ð$>ÐRVÑWˆØ×ÑÔØ×Ñ˜[¬%×*>Ñ*>Ô?Ø×%Ñ% lÓ3ˆØ×Ñ˜Ð!7Õ8r=   c                óª  • [        5       n[        5       n[        X/SS9nUR                  5         U R                  U[        R
                  5        U R                  U[        R
                  5        U R                  U[        R                  5      nUR                  nU R                  UR                  R                  [        R
                  5      5        g)zy
When cancelling an unfired L{DeferredList} with the flag
C{fireOnOneErrback} set, cancel every L{Deferred} in the list.
Trø   N)r!   r#   r&  r'  r   r   rÿ   rb   r`   r   ra   )rc   r)  r*  r+  ÚdeferredListFailurer  s         r:   Ú+test_cancelDeferredListWithFireOnOneErrbackÚ9DeferredTests.test_cancelDeferredListWithFireOnOneErrbackú  s¡   € ô
 '/£jˆÜ&.£jˆÜ# [Ð$>ÐQUÑVˆØ×ÑÔØ×Ñ˜[¬%×*>Ñ*>Ô?Ø×Ñ˜[¬%×*>Ñ*>Ô?Ø"×2Ñ2°<Ä×AQÑAQÓRÐØ(×.Ñ.ˆ
Ø�‰˜
×-Ñ-×3Ñ3´E×4HÑ4HÓIÕJr=   c                óT  • [        [        5      n[        [        5      n[        X/SS9nUR                  5         U R	                  U5      nU R                  US   S   5        U R                  US   S   S5        U R                  US   S   5        U R                  US   S   S5        g)z×
When cancelling an unfired L{DeferredList} with the flag
C{fireOnOneErrback} set, if all the L{Deferred} callbacks
in its canceller, the L{DeferredList} will callback with a
C{list} of (success, result) C{tuple}s.
Trø   r   rZ   rN   N)r!   rS   r#   r&  r/  r`   r^   r1  s        r:   Ú?test_cancelDeferredListWithFireOnOneErrbackAllDeferredsCallbackÚMDeferredTests.test_cancelDeferredListWithFireOnOneErrbackAllDeferredsCallback	  s    € ô &.Ô.CÓ%DˆÜ%-Ô.CÓ%DˆÜ# [Ð$>ÐQUÑVˆØ×ÑÔØ×%Ñ% lÓ3ˆØ�‰˜˜q™	 !™Ô%Ø×Ñ˜ ™ 1™Ð'8Ô9Ø�‰˜˜q™	 !™Ô%Ø×Ñ˜ ™ 1™Ð'8Õ9r=   c                ó@  • [        5       n[        5       nX/n[        U5      n[        5       nUR                  U5        UR                  5         U R	                  U[
        R                  5        U R	                  U[
        R                  5        U R                  U5        g)zO
Cancelling a L{DeferredList} will cancel the original
L{Deferred}s passed in.
N)r!   r#   r]   r&  r'  r   r   ÚassertNoResult)rc   r)  r*  ÚargumentListr+  ÚdeferredThrees         r:   Ú,test_cancelDeferredListWithOriginalDeferredsÚ:DeferredTests.test_cancelDeferredListWithOriginalDeferreds  s   € ô
 '/£jˆÜ&.£jˆØ#Ð1ˆÜ# LÓ1ˆÜ(0«
ˆØ×Ñ˜MÔ*Ø×ÑÔØ×Ñ˜[¬%×*>Ñ*>Ô?Ø×Ñ˜[¬%×*>Ñ*>Ô?Ø×Ñ˜MÕ*r=   c                ó  • SS jn[        U5      n[        5       n[        X#/5      nUR                  5         U R                  U[        R
                  5        U R                  [        5      nU R                  [        U5      S5        g)zŽ
Cancelling a L{DeferredList} will cancel every L{Deferred}
in the list even exceptions raised from the C{cancel} method of the
L{Deferred}s.
c                ó   • [        S5      e)z`
A L{Deferred} canceller that raises an exception.

@param deferred: The cancelled L{Deferred}.
Útest)ro   rQ   s    r:   ÚcancellerRaisesExceptionÚTDeferredTests.test_cancelDeferredListWithException.<locals>.cancellerRaisesException1  s   € ô ˜vÓ&Ð&r=   rZ   N)rR   úDeferred[object]r?   r„   )
r!   r#   r&  r'  r   r   rq   ro   r^   r_   )rc   rJ  r)  r*  r+  rx   s         r:   Ú$test_cancelDeferredListWithExceptionÚ2DeferredTests.test_cancelDeferredListWithException*  sn   € ô	'ô '/Ð/GÓ&HˆÜ&.£jˆÜ# [Ð$>Ó?ˆØ×ÑÔØ×Ñ˜[¬%×*>Ñ*>Ô?Ø×'Ñ'¬Ó5ˆØ×Ñœ˜V› aÕ(r=   c                ó¦   • [        5       n[        5       n[        X/SS9nUR                  S5        UR                  5         U R	                  U5        g)z¼
When a L{DeferredList} has fired because one L{Deferred} in
the list fired with a non-failure result, the cancellation will do
nothing instead of cancelling the rest of the L{Deferred}s.
Trñ   N)r!   r#   rP   r&  rB  r(  s       r:   Ú)test_cancelFiredOnOneCallbackDeferredListÚ7DeferredTests.test_cancelFiredOnOneCallbackDeferredListA  sJ   € ô '/£jˆÜ&.£jˆÜ# [Ð$>ÐRVÑWˆØ×Ñ˜TÔ"Ø×ÑÔØ×Ñ˜KÕ(r=   c                ó$  • [        5       n[        5       n[        X/SS9nUR                  [        S5      5        UR	                  5         U R                  U5        U R                  U[        5        U R                  U[        R                  5        g)z¸
When a L{DeferredList} has fired because one L{Deferred} in
the list fired with a failure result, the cancellation will do
nothing instead of cancelling the rest of the L{Deferred}s.
Trø   rI  N)	r!   r#   rÆ   rD   r&  rB  r'  r   rÿ   r(  s       r:   Ú(test_cancelFiredOnOneErrbackDeferredListÚ6DeferredTests.test_cancelFiredOnOneErrbackDeferredListN  su   € ô '/£jˆÜ&.£jˆÜ# [Ð$>ÐQUÑVˆØ×ÑœL¨Ó0Ô1Ø×ÑÔØ×Ñ˜KÔ(Ø×Ñ˜[¬,Ô7Ø×Ñ˜\¬5×+;Ñ+;Õ<r=   c                ó�   • / n[         R                  " S5      nUR                  UR                  5        U R	                  US/5        g )NÚsuccess)r   Úsucceedrª   r]   r^   ©rc   ÚlÚds      r:   ÚtestImmediateSuccessÚ"DeferredTests.testImmediateSuccess]  s7   € ØˆÜ Ÿ=š=¨Ó3ˆØ	�‰�a—h‘hÔØ×Ñ˜˜Y˜KÕ(r=   c                ó²   • [        5       nUR                  S5        [        R                  " S5      nU R	                  UR
                  UR
                  5        g)zI
C{defer.succeed(x)} is the same as as C{d = Deferred(); d.callback(x)}.
rV  N)r!   rP   r   rW  r^   Ú__dict__)rc   rZ  r  s      r:   Ú test_succeedMatchesManualSuccessÚ.DeferredTests.test_succeedMatchesManualSuccessc  s=   € ô $›:ˆØ	�
‰
�9ÔÜ!ŸMšM¨)Ó4ˆØ×Ñ˜Ÿ™ R§[¡[Õ1r=   c                óÌ   • / n[         R                  " [        S5      5      nUR                  UR                  5        U R                  [        US   R                  5      S5        g ©NÚfailr   )r   rc  rD   r\   r]   r^   rË   rb   rX  s      r:   ÚtestImmediateFailureÚ"DeferredTests.testImmediateFailurel  sF   € ØˆÜ!ŸJšJ¤|°FÓ';Ó<ˆØ	�‰�Q—X‘XÔØ×Ñœ˜Q˜q™TŸZ™Z›¨&Õ1r=   c                ó0  • / n[         R                  " [        S5      5      nUR                  5         UR	                  UR
                  5        U R                  U/ 5        UR                  5         U R                  [        US   R                  5      S5        g rb  )
r   rc  rD   Úpauser\   r]   r^   ÚunpauserË   rb   rX  s      r:   ÚtestPausedFailureÚDeferredTests.testPausedFailurer  sh   € ØˆÜ�JŠJ”| FÓ+Ó,ˆØ	�‰Œ	Ø	�‰�Q—X‘XÔØ×Ñ˜˜BÔØ	�	‰	ŒØ×Ñœ˜Q˜q™TŸZ™Z›¨&Õ1r=   c                óÀ  • / n[        5       nUR                  S 5      R                  UR                  5        UR	                  S5        U R                  US   R                  [        5        / n[         [           " 5       nUR                  S 5      R                  UR                  5        UR	                  S5        U R                  US   R                  [        5        g )Nc                ó   • SS-  $ ©NrZ   r   rF   ©Ú_s    r:   r  Ú2DeferredTests.testCallbackErrors.<locals>.<lambda>~  s   €   Q¢r=   rZ   r   c                ó(   • [        [        5       5      $ r4   )r0   ÚZeroDivisionErrorrn  s    r:   r  rp  ƒ  s   € ¤Ô):Ó)<Ô!=r=   )	r!   rª   r\   r]   rP   ÚassertIsInstancerb   rr  Úint)rc   rY  rZ  r  s       r:   ÚtestCallbackErrorsÚ DeferredTests.testCallbackErrors{  sž   € ØˆÜ#›:ˆØ	�‰Ñ&Ó'×2Ñ2°1·8±8Ô<Ø	�
‰
�1ŒØ×Ñ˜a ™dŸj™jÔ*;Ô<ØˆÜ”cŠ]‹_ˆØ
�‰Ñ=Ó>×IÑIÈ!Ï(É(ÔSØ
�‰�AŒØ×Ñ˜a ™dŸj™jÔ*;Õ<r=   c                óŽ   • [        5       nUR                  5         UR                  U R                  5        UR	                  5         g r4   )r!   rg  rª   r›   rh  ©rc   rZ  s     r:   ÚtestUnpauseBeforeCallbackÚ'DeferredTests.testUnpauseBeforeCallback‡  s+   € Ü$›JˆØ	�‰Œ	Ø	�‰�d—n‘nÔ%Ø	�	‰	�r=   c                óZ  ^• [        5       n[        5       mTR                  5         UR                  U4S j5        UR                  U R                  5        UR	                  S5        U R                  U R                  S5        TR	                  S5        U R                  U R                  S5        TR                  5         U R                  U R                  S5        U R                  c   S5       eU R                  U R                  S	   S	   SS
R                  U R                  5      5        g)zƒ
Callbacks passed to L{Deferred.addCallback} can return Deferreds and
the next callback will not be run until that Deferred fires.
c                ó   >• T$ r4   rF   )Úrr  s    €r:   r  Ú<DeferredTests.test_callbackReturnsDeferred.<locals>.<lambda>•  s   ø€ ¡r=   rZ   z Should not have been called yet.rá   z&Still should not have been called yet.zShould have been called nowNz%make that legible to the type checkerr   z/Result should have been from second deferred:{})r!   rg  rª   r›   rP   r«   rŽ   rh  ÚassertIsNotNoneÚassertEqualsÚformat©rc   r	  r  s     @r:   Útest_callbackReturnsDeferredÚ*DeferredTests.test_callbackReturnsDeferred�  sô   ø€ ô
 %›JˆÜ$›JˆØ
�‰Œ
Ø
�‰”|Ô$Ø
�‰�t—~‘~Ô&Ø
�‰�AŒØ×Ñ˜$×.Ñ.Ð0RÔSØ
�‰�AŒØ×ÑØ× Ñ Ð"Jô	
ð 	�
‰
ŒØ×Ñ˜T×1Ñ1Ð3PÔQØ×#Ñ#Ñ/ÐXÐ1XÓXÐ/Ø×ÑØ× Ñ  Ñ# AÑ&ØØ=×DÑDØ×$Ñ$óõ	
r=   c                ó®  ^^• [        5       nSm[        5       mSUU4S jjnUR                  S5        U R                  U R	                  UR                  U5      5      S5        [         [           " 5       nSmUR                  S5        U R                  U R                  UR                  U5      R                  U5      [        5      R                  T5        g)z6
Callbacks passed to addCallback may return Failures.
Fc                ó2   >• T(       a  [        T5      $ U S-   $ ©NrZ   r/   )rt   ÚrteÚ
shouldFails    €€r:   Ú	maybeFailÚADeferredTests.test_callbackMaybeReturnsFailure.<locals>.maybeFail±  s   ø€ æÜ˜s“|Ð#à ‘zÐ!r=   é   é   TN)rt   rt  r?   zUnion[int, Failure])
r!   ro   rP   r^   r/  rª   rt  rr   r'  rb   )rc   rZ  rŠ  rˆ  r‰  s      @@r:   Ú test_callbackMaybeReturnsFailureÚ.DeferredTests.test_callbackMaybeReturnsFailure¨  s¬   ù€ ô $›:ˆàˆ
Ü‹nˆ÷	"ð 	"ð 	
�
‰
�1ŒØ×Ñ˜×-Ñ-¨a¯m©m¸IÓ.FÓGÈÔKÜ”SŠM‹OˆØˆ
Ø	�
‰
�1ŒØ�‰Ø× Ñ à—‘˜iÓ(×4Ñ4°YÓ?Üó÷ ‰eØõ	
r=   c                óT  ^^• [        5       n[        5       m/ mSU4S jjnSU4S jjnUR                  U5      R                  U5        UR                  [	        5       5        U R                  U5        U R                  T/ 5        TR                  S5        U R                  TS/5        g)zW
Errbacks passed to L{Deferred.addErrback} can return Deferreds just as
callbacks can.
rt   c                ó   >• T$ r4   rF   )rt   r  s    €r:   ÚasyncErrbackÚ?DeferredTests.test_errbackReturnsDeferred.<locals>.asyncErrbackÏ  s   ø€ ØˆIr=   c                ó(   >• TR                  U 5        g r4   rï   )rt   ÚresultValuess    €r:   ÚsyncCallbackÚ?DeferredTests.test_errbackReturnsDeferred.<locals>.syncCallbackÒ  s   ø€ Ø×Ñ Õ'r=   N)rt   r0   r?   úDeferred[str])rt   zUnion[str, int]r?   r„   )r!   r\   rª   rÆ   Ú
ValueErrorrB  r^   rP   )rc   rZ  r’  r–  r  r•  s       @@r:   Útest_errbackReturnsDeferredÚ)DeferredTests.test_errbackReturnsDeferredÆ  s…   ù€ ô
 $›:ˆÜ$›JˆØˆ÷	÷	(ð 	
�‰�\Ó"×.Ñ.¨|Ô<Ø	�	‰	”*“,ÔØ×Ñ˜AÔØ×Ñ˜ rÔ*Ø
�‰�HÔØ×Ñ˜¨ zÕ2r=   c                ór  ^• [        5       n[        5       mTR                  U5        TR                  5         [        5       nUR	                  U4S j5        UR                  S5        / nUR	                  UR
                  5        U R                  U/ 5        TR                  5         U R                  X1/5        g)z£
When a paused Deferred with a result is returned from a callback on
another Deferred, the other Deferred is chained to the first and waits
for it to be unpaused.
c                ó   >• T$ r4   rF   )ÚignoredÚpauseds    €r:   r  ÚDDeferredTests.test_chainedPausedDeferredWithResult.<locals>.<lambda>ç  s   ø€ ©Fr=   N)r>   r!   rP   rg  rª   r]   r^   rh  )rc   ÚexpectedÚchainedrt   rŸ  s       @r:   Ú$test_chainedPausedDeferredWithResultÚ2DeferredTests.test_chainedPausedDeferredWithResultÜ  s�   ø€ ô “8ˆÜ#+£:ˆØ�‰˜Ô!Ø�‰ŒÜ"*£*ˆØ×ÑÔ2Ô3Ø×Ñ˜Ôà!ˆØ×Ñ˜FŸM™MÔ*Ø×Ñ˜ Ô$Ø�‰ÔØ×Ñ˜ Õ,r=   c                ó  ^• [        5       n[        5       mUR                  U4S j5        UR                  S5        UR                  5         TR                  S5        / nTR                  UR                  5        U R                  US/5        g)z�
A paused Deferred encountered while pushing a result forward through a
chain does not prevent earlier Deferreds from continuing to execute
their callbacks.
c                ó   >• T$ r4   rF   ©rž  Úseconds    €r:   r  Ú:DeferredTests.test_pausedDeferredChained.<locals>.<lambda>ø  ó   ø€ ©&r=   N)r!   rª   rP   rg  r]   r^   )rc   Úfirstrt   r¨  s      @r:   Útest_pausedDeferredChainedÚ(DeferredTests.test_pausedDeferredChainedð  sl   ø€ ô !)£
ˆÜ!)£ˆØ×ÑÔ0Ô1Ø�‰�tÔØ�‰ŒØ�‰˜ÔØˆØ×Ñ˜6Ÿ=™=Ô)Ø×Ñ˜ $ Õ(r=   c                ó@  • / n[         R                  " [         R                  " S5      [         R                  " S5      /5      R                  UR                  5        U R                  USS//5        / n[         R                  " S5      [         R                  " [        5       5      /n[         R                  " U5      R                  UR                  5        U R                  [        U5      S5        U R                  US   [        5        US   R                  S 5        g )NrZ   rá   r   c                ó   • gr‡  rF   r  s    r:   r  Ú2DeferredTests.test_gatherResults.<locals>.<lambda>  s   €  1r=   )r   ÚgatherResultsrW  rª   r]   r^   rc  r™  r\   r_   rs  r0   )rc   Úresultsrx   rê   s       r:   Útest_gatherResultsÚ DeferredTests.test_gatherResults   sÐ   € à#%ˆÜ×ÒœUŸ]š]¨1Ó-¬u¯}ª}¸QÓ/?Ð@ÓA×MÑMØ�N‰Nô	
ð 	×Ñ˜ A q 6 (Ô+à "ˆÜ�mŠm˜AÓ¤§
¢
¬:«<Ó 8Ð9ˆÜ×Ò˜BÓ×*Ñ*¨6¯=©=Ô9Ø×Ñœ˜V› aÔ(Ø×Ñ˜f Q™i¬Ô1à
ˆ1‰×Ñ™Õ%r=   c                ó&  • [         R                  " S5      n[         R                  " [        S5      5      n[         R                  " X/SS9n/ nUR                  UR                  5        / nUR                  UR                  5        U R                  [        U5      [        U5      4S5        U R                  US   R                  [         R                  5        US   R                  R                  nU R                  UR                  [        5        g)z²
If a L{Deferred} in the list passed to L{gatherResults} fires with a
failure and C{consumerErrors} is C{True}, the failure is converted to a
L{None} result on that L{Deferred}.
rZ   zoh noesTr  ©r   rZ   r   N)r   rW  rc  ro   r±  r\   r]   r^   r_   rs  rb   rÿ   r   )rc   ÚdgoodÚdbadrZ  ÚunconsumedErrorsÚgatheredErrorsr  s          r:   Ú#test_gatherResultsWithConsumeErrorsÚ1DeferredTests.test_gatherResultsWithConsumeErrors  sÖ   € ô —’˜aÓ ˆÜ�zŠzœ, yÓ1Ó2ˆÜ×Ò  ¸TÑBˆØ*,ÐØ�‰Ð(×/Ñ/Ô0Ø(*ˆØ	�‰�^×*Ñ*Ô+à×Ñœ#Ð.Ó/´°^Ó1DÐEÀvÔNØ×Ñ˜n¨QÑ/×5Ñ5´u×7GÑ7GÔHØ# AÑ&×,Ñ,×7Ñ7ˆ
Ø×Ñ˜j×.Ñ.´Õ=r=   c                óÂ  • [        5       n[        5       n[        R                  " X/5      nUR                  5         U R	                  U[        R
                  5        U R	                  U[        R
                  5        U R	                  U[        R                  5      nUR                  nU R                  UR                  R                  [        R
                  5      5        g)zf
When cancelling the L{defer.gatherResults} call, all the
L{Deferred}s in the list will be cancelled.
N)r!   r   r±  r&  r'  r   rÿ   rb   r`   r   ra   )rc   r)  r*  rt   ÚgatherResultsFailurer  s         r:   Útest_cancelGatherResultsÚ&DeferredTests.test_cancelGatherResults$  s¡   € ô
 '/£jˆÜ&.£jˆÜ×$Ò$ kÐ%?Ó@ˆØ�‰ŒØ×Ñ˜[¬%×*>Ñ*>Ô?Ø×Ñ˜[¬%×*>Ñ*>Ô?Ø#×3Ñ3°F¼E×<LÑ<LÓMÐØ)×/Ñ/ˆ
Ø�‰˜
×-Ñ-×3Ñ3´E×4HÑ4HÓIÕJr=   c                ó  • [        [        5      n[        [        5      n[        R                  " X/5      nUR	                  5         U R                  U5      nU R                  US   S5        U R                  US   S5        g)zÎ
When cancelling the L{defer.gatherResults} call, if all the
L{Deferred}s callback in their canceller, the L{Deferred}
returned by L{defer.gatherResults} will be callbacked with the C{list}
of the results.
r   rN   rZ   N)r!   rS   r   r±  r&  r/  r^   )rc   r)  r*  rt   ÚcallbackResults        r:   Ú0test_cancelGatherResultsWithAllDeferredsCallbackÚ>DeferredTests.test_cancelGatherResultsWithAllDeferredsCallback3  sr   € ô &.Ô.CÓ%DˆÜ%-Ô.CÓ%DˆÜ×$Ò$ kÐ%?Ó@ˆØ�‰ŒØ×-Ñ-¨fÓ5ˆØ×Ñ˜¨Ñ*Ð,=Ô>Ø×Ñ˜¨Ñ*Ð,=Õ>r=   c                ó&  ^• [        5       m/ n/ n[        R                  " U4S j5      nUR                  UR                  UR                  5        U R                  U/ 5        U R                  [        U5      S5        U R                  US   T5        g)zw
L{defer.maybeDeferred} should retrieve the result of a synchronous
function and pass it to its resulting L{Deferred}.
c                 ó   >• T $ r4   rF   ©rt   s   €r:   r  Ú6DeferredTests.test_maybeDeferredSync.<locals>.<lambda>J  s   ø€ ©r=   rZ   r   N)r>   r   ÚmaybeDeferredrÅ   r]   r^   r_   ÚassertIdentical)rc   r²  rx   rZ  rt   s       @r:   Útest_maybeDeferredSyncÚ$DeferredTests.test_maybeDeferredSyncB  st   ø€ ô
 “ˆØ "ˆØ "ˆÜ×Ò¤Ó/ˆØ	�‰�w—~‘~ v§}¡}Ô5Ø×Ñ˜ Ô$Ø×Ñœ˜W› qÔ)Ø×Ñ˜W Q™Z¨Õ0r=   c                ó  • SS jn/ n/ n[         R                  " US5      n[        U[        [           5        UR                  UR                  UR                  5        U R                  U/ 5        U R                  US/5        g)zF
L{defer.maybeDeferred} should pass arguments to the called function.
c                ó   • U S-   $ )Né   rF   ©Úxs    r:   ÚplusFiveÚ>DeferredTests.test_maybeDeferredSyncWithArgs.<locals>.plusFiveU  s   € Ø�q‘5ˆLr=   é
   é   N)rÑ  rt  r?   rt  )r   rÉ  r   r!   rt  rÅ   r]   r^   )rc   rÒ  r²  rx   rZ  s        r:   Útest_maybeDeferredSyncWithArgsÚ,DeferredTests.test_maybeDeferredSyncWithArgsP  sk   € ô
	ð  ˆØ "ˆÜ×Ò ¨"Ó-ˆÜ�A”x¤‘}Ô%Ø	�‰�w—~‘~ v§}¡}Ô5Ø×Ñ˜ Ô$Ø×Ñ˜ 2 $Õ'r=   c                ód  ^• [        S5      mSU4S jjn/ n/ n[        R                  " U5      R                  UR                  UR                  5        U R                  U/ 5        U R                  [        U5      S5        U R                  [        US   R                  5      [        T5      5        g)z‚
L{defer.maybeDeferred} should catch an exception raised by a synchronous
function and errback its resulting L{Deferred} with it.
zthat value is unacceptablec                 ó   >• T er4   rF   ©r¡  s   €r:   ÚraisesExceptionÚFDeferredTests.test_maybeDeferredSyncException.<locals>.raisesExceptiong  s   ø€ ØˆNr=   rZ   r   N)r?   r   )	r™  r   rÉ  rÅ   r]   r^   r_   rË   rb   )rc   rÛ  r²  rx   r¡  s       @r:   Útest_maybeDeferredSyncExceptionÚ-DeferredTests.test_maybeDeferredSyncException`  s‰   ø€ ô
 Ð:Ó;ˆ÷	ð  ˆØ "ˆÜ×Ò˜OÓ,×9Ñ9¸'¿.¹.È&Ï-É-ÔXØ×Ñ˜ "Ô%Ø×Ñœ˜V› aÔ(Ø×Ñœ˜V A™YŸ_™_Ó-¬s°8«}Õ=r=   c                óR  ^•  SS-     / n/ n[        R                  " U4S j5      nUR	                  UR
                  UR
                  5        U R                  U/ 5        U R                  [        U5      S5        U R                  US   T5        g! [          a    [        5       m N�f = f)z_
L{defer.maybeDeferred} should handle a L{Failure} returned by a
function and errback with it.
Ú10rÏ  c                 ó   >• T $ r4   rF   rÚ  s   €r:   r  Ú=DeferredTests.test_maybeDeferredSyncFailure.<locals>.<lambda>}  s   ø€ ©r=   rZ   r   N)	Ú	TypeErrorr0   r   rÉ  rÅ   r]   r^   r_   rÊ  )rc   r²  rx   rZ  r¡  s       @r:   Útest_maybeDeferredSyncFailureÚ+DeferredTests.test_maybeDeferredSyncFailureq  s’   ø€ ð
	!Ø�1ŠHð  ˆØ "ˆÜ×ÒÔ 0Ó1ˆØ	�‰�w—~‘~ v§}¡}Ô5Ø×Ñ˜ "Ô%Ø×Ñœ˜V› aÔ(Ø×Ñ˜V A™Y¨Õ1øô ó 	!Ü“yŠHð	!ús   ƒB ÂB&Â%B&c                óÐ   ^• [        5       m[        R                  " U4S j5      nTR                  S5        / nUR	                  UR
                  5        U R                  US/5        g)ze
L{defer.maybeDeferred} should let L{Deferred} instance pass by
so that original result is the same.
c                 ó   >• T $ r4   rF   ©r	  s   €r:   r  Ú7DeferredTests.test_maybeDeferredAsync.<locals>.<lambda>‰  s   ø€ ©r=   ÚSuccessN)r!   r   rÉ  rP   rª   r]   r^   )rc   r  rt   r	  s      @r:   Útest_maybeDeferredAsyncÚ%DeferredTests.test_maybeDeferredAsyncƒ  sO   ø€ ô
 %›JˆÜ× Ò ¤Ó,ˆØ
�‰�IÔØˆØ
�‰�v—}‘}Ô%Ø×Ñ˜ ) Õ-r=   c                ó¾   ^• [        5       m[        R                  " U4S j5      nTR                  [	        [        5       5      5        U R                  U[
        5        g)z‚
L{defer.maybeDeferred} should let L{Deferred} instance pass by
so that L{Failure} returned by the original instance is the
same.
c                 ó   >• T $ r4   rF   rè  s   €r:   r  Ú<DeferredTests.test_maybeDeferredAsyncError.<locals>.<lambda>–  s   ø€ ¹r=   N)r!   r   rÉ  rÆ   r0   ro   rg   )rc   r  r	  s     @r:   Útest_maybeDeferredAsyncErrorÚ*DeferredTests.test_maybeDeferredAsyncError�  s?   ø€ ô &›ZˆÜ"×0Ò0´Ó<ˆØ
�
‰
”7œ<›>Ó*Ô+Ø×#Ñ# B¬Õ5r=   c                óª   • SS jn[         R                  " U5      n[        U[        [           5        U R                  U R                  U5      S5        g)úŸ
When called with a coroutine function L{defer.maybeDeferred} returns a
L{defer.Deferred} which has the same result as the coroutine returned
by the function.
c               “  ó   #   • g7f©Nr�  rF   rF   r=   r:   r9   Ú;DeferredTests.test_maybeDeferredCoroutineSuccess.<locals>.f¡  ó   é € Øùó   ‚r�  N©r?   rt  )r   rÉ  r   r!   rt  r^   r/  )rc   r9   ÚcoroutineDeferreds      r:   Ú"test_maybeDeferredCoroutineSuccessÚ0DeferredTests.test_maybeDeferredCoroutineSuccessš  sE   € ô	ô "×/Ò/°Ó2ÐÜÐ%¤x´¡}Ô5Ø×Ñ˜×-Ñ-Ð.?Ó@À!ÕDr=   c                óè   ^• SS jmSU4S jjnSS jn[         R                  " U5      n[        U[        [           5        UR                  U5      nU R                  U R                  U5      S5        g)	ró  c               “  ó   #   • g7frõ  rF   rF   r=   r:   r9   ÚCDeferredTests.test_maybeDeferredCoroutineSuccessIndirect.<locals>.f¯  r÷  rø  c                 ó   >• T " 5       $ r4   rF   ©r9   s   €r:   ÚgÚCDeferredTests.test_maybeDeferredCoroutineSuccessIndirect.<locals>.g´  ó
   ø€ Ù“3ˆJr=   c                ó   • U S-   $ r‡  rF   rÇ  s    r:   ÚtypedCallbackÚODeferredTests.test_maybeDeferredCoroutineSuccessIndirect.<locals>.typedCallback¹  s   € Ø˜A‘:Ðr=   é   Nrù  )r?   z"Coroutine[Deferred[int], Any, Any])rt   rt  r?   rt  )r   rÉ  r   r!   r   rª   r^   r/  )rc   r  r  rú  ÚmodifiedDeferredr9   s        @r:   Ú*test_maybeDeferredCoroutineSuccessIndirectÚ8DeferredTests.test_maybeDeferredCoroutineSuccessIndirect¨  sa   ø€ ô	÷
	ô
	ô "×/Ò/°Ó2ÐÜÐ%¤x´¡}Ô5Ø,×8Ñ8¸ÓGÐØ×Ñ˜×-Ñ-Ð.>Ó?ÀÕCr=   c                óÊ   ^^•  " S S[         5      mSU4S jjmSU4S jjn[        U R                  [        R                  " U5      5      R
                  [        T5      5        g)z±
When called with a coroutine function L{defer.maybeDeferred} returns a
L{defer.Deferred} which has a L{Failure} result wrapping the exception
raised by the coroutine function.
c                  ó   • \ rS rSrSrg)ÚGDeferredTests.test_maybeDeferredCoroutineFailure.<locals>.SomeExceptioniÈ  rF   NrG   rF   r=   r:   ÚSomeExceptionr  È  ó   † Úr=   r  c               “  ó   >#   • T " 5       e7fr4   rF   )r  s   €r:   r9   Ú;DeferredTests.test_maybeDeferredCoroutineFailure.<locals>.fË  s   øé € Ù“/Ð!ùs   ƒc                 ó   >• T " 5       $ r4   rF   r  s   €r:   r  Ú;DeferredTests.test_maybeDeferredCoroutineFailure.<locals>.gÐ  r  r=   Nr‰   )r?   zCoroutine[None, None, None])Ú	Exceptionr   r'  r   rÉ  rþ   r   )rc   r  r  r9   s     @@r:   Ú"test_maybeDeferredCoroutineFailureÚ0DeferredTests.test_maybeDeferredCoroutineFailureÁ  sJ   ù€ ô	œIô 	÷	"÷
	ô 	Ø× Ñ ¤×!4Ò!4°QÓ!7Ó8×=Ñ=Ü�]Ó#õ	
r=   c                ó˜  ^^^• / m/ m[        5       mSUUU4S jjn[        R                  " S5      nUR                  U5        TR	                  S5        UR                  TR
                  5        TR                  TR
                  5        UR                  TR
                  5        U R                  / T5        U R                  T/ SQ5        g)zè
When a L{Deferred} encounters a result which is another L{Deferred}
which is waiting on a third L{Deferred}, the middle L{Deferred}'s
callbacks are executed after the third L{Deferred} fires and before the
first receives a result.
c                óò   >• TR                  SU 45        [        R                  " S5      nSUU4S jjnSU4S jjnUR                  U5      R                  U5        UR	                  TR                   5        U$ )Nústart-of-cbÚinnerc                ó*   >• TR                  S5        T$ ©N©ÚfirstCallbackr  rï   ©rt   r  r²  s    €€r:   r  ÚMDeferredTests.test_innerCallbacksPreserved.<locals>.cb.<locals>.firstCallbackç  s   ø€ Ø—‘Ð9Ô:Ø�r=   c                ó4   >• TR                  SU 45        U S-  $ ©NÚsecondCallbackrá   rï   ©rt   r²  s    €r:   r$  ÚNDeferredTests.test_innerCallbacksPreserved.<locals>.cb.<locals>.secondCallbackë  ó   ø€ Ø—‘Ð 0°&Ð9Ô:Ø ‘zÐ!r=   ©rt   rË   r?   r˜  ©rt   rË   r?   rË   ©r]   r   rW  rª   r\   ©rt   rZ  r  r$  rf   r  r²  s       €€€r:   rÖ   Ú6DeferredTests.test_innerCallbacksPreserved.<locals>.cbã  s_   ø€ Ø�N‰N˜M¨6Ð2Ô3Ü—’˜gÓ&ˆA÷ð ÷"ð �M‰M˜-Ó(×4Ñ4°^ÔDØ�L‰L˜Ÿ™Ô)ØˆHr=   ÚouterÚorange©©r  r-  r  )r$  r.  ÚorangeorangeNr(  )r!   r   rW  rª   rP   r]   r\   r^   ©rc   rÖ   r-  rf   r  r²  s      @@@r:   Útest_innerCallbacksPreservedÚ*DeferredTests.test_innerCallbacksPreservedØ  s¦   ú€ ð 68ˆØ"$ˆÜ'›zˆ÷	ñ 	ô  —’˜gÓ&ˆØ×Ñ˜"ÔØ�‰�xÔ Ø×Ñ˜'Ÿ.™.Ô)Ø×Ñ˜Ÿ™Ô)Ø×Ñ˜Ÿ™Ô)Ø×Ñ˜˜XÔ&Ø×ÑØòõ	
r=   c                óT  ^^^• / m/ m[        5       mSUUU4S jjn[        R                  " S5      R                  U5      R	                  TR
                  5        U R                  SS/T5        TR                  S5        U R                  / T5        U R                  TSSSS/4/5        g)	zØ
The continue callback of a L{Deferred} waiting for another L{Deferred}
is not necessarily the first one. This is somewhat a whitebox test
checking that we search for that callback among the whole list of
callbacks.
c                óø   >• TR                  SU 45        [        5       nSUU4S jjnSU4S jjnUR                  U5      R                  U5      R                  TR                   5      nUR	                  S 5        U$ )NrÖ   c                óX   >• TR                  SU 45        [        R                  " T/5      $ ©Nr  ©r]   r   r±  ©rt   Úar²  s    €€r:   r  ÚNDeferredTests.test_continueCallbackNotFirst.<locals>.cb.<locals>.firstCallback  ó'   ø€ Ø—‘ °Ð8Ô9Ü×*Ò*¨A¨3Ó/Ð/r=   c                ó,   >• TR                  SU 45        g ©Nr$  rï   r%  s    €r:   r$  ÚODeferredTests.test_continueCallbackNotFirst.<locals>.cb.<locals>.secondCallback  ó   ø€ Ø—‘Ð 0°&Ð9Õ:r=   ©rt   r„   r?   úDeferred[List[str]]©rt   ú	List[str]r?   r„   ©r]   r!   rª   r\   rP   ©rt   rZ  r  r$  Úreturnerr;  rf   r²  s        €€€r:   rÖ   Ú7DeferredTests.test_continueCallbackNotFirst.<locals>.cb  óg   ø€ Ø�N‰N˜D &˜>Ô*Ü (£
ˆA÷0ð 0÷;ð —‘˜mÓ,ß‘˜^Ó,ß‘˜HŸO™OÓ,ð ð
 �J‰J�tÔØˆOr=   r-  ©rÖ   r-  ©r  NÚwithersr$  N©rt   rË   r?   úDeferred[None])r!   r   rW  rª   r\   r]   r^   rP   )rc   rÖ   r;  rf   r²  s     @@@r:   Útest_continueCallbackNotFirstÚ+DeferredTests.test_continueCallbackNotFirst  s    ú€ ð BDˆØ"$ˆÜ#›:ˆ÷	ñ 	ô& 	�Š�gÓ×*Ñ*¨2Ó.×9Ñ9¸(¿/¹/ÔJØ×Ñ˜/Ð+BÐCÀWÔMØ	�
‰
�9ÔØ×Ñ˜˜XÔ&Ø×ÑØØÐ5Ð8HÈ9È+Ð7VÐWõ	
r=   c                ó’  ^^^• / m/ m[        5       mS
UUU4S jjn[        5       nUR                  U5        UR                  U4S j5        UR                  TR                  5        UR	                  S5        U R                  SS/T5        TR	                  S5        U R                  / T5        U R                  TSSSS/4S/5        g	)z£
A callback added to a L{Deferred} after a previous callback attached
another L{Deferred} as a result is run after the callbacks of the other
L{Deferred} are run.
c                óø   >• TR                  SU 45        [        5       nSUU4S jjnSU4S jjnUR                  U5      R                  U5      R                  TR                   5      nUR	                  S 5        U$ )NrÖ   c                óX   >• TR                  SU 45        [        R                  " T/5      $ r8  r9  r:  s    €€r:   r  ÚLDeferredTests.test_callbackOrderPreserved.<locals>.cb.<locals>.firstCallback9  r=  r=   c                ó,   >• TR                  SU 45        g r?  rï   r%  s    €r:   r$  ÚMDeferredTests.test_callbackOrderPreserved.<locals>.cb.<locals>.secondCallback=  rA  r=   rB  rD  rF  rG  s        €€€r:   rÖ   Ú5DeferredTests.test_callbackOrderPreserved.<locals>.cb5  rJ  r=   c                ó&   >• TR                  S5      $ )N©ÚfinalNrï   )rÑ  r²  s    €r:   r  Ú;DeferredTests.test_callbackOrderPreserved.<locals>.<lambda>J  s   ø€  G§N¡N°?Ô$Cr=   r-  rK  rL  rM  r$  rZ  NrN  )r!   rª   r\   r]   rP   r^   )rc   rÖ   r-  r;  rf   r²  s      @@@r:   Útest_callbackOrderPreservedÚ)DeferredTests.test_callbackOrderPreserved+  sÁ   ú€ ð BDˆØ"$ˆÜ#›:ˆ÷	ñ 	ô&  (›zˆØ×Ñ˜"ÔØ×ÑÔCÔDØ×Ñ˜Ÿ™Ô)Ø�‰�wÔØ×Ñ˜/Ð+BÐCÀWÔMØ	�
‰
�9ÔØ×Ñ˜˜XÔ&Ø×ÑØàØ'Ø! I ;Ð/Øð	õ	
r=   c                óä   ^^^• [        5       m/ mSU4S jjmSU4S jjnSUUU4S jjnTR                  U5        TR                  U5        TR                  S5        U R                  T/ SQ5        g)zw
A callback added to a L{Deferred} by a callback on that L{Deferred}
should be added to the end of the callback chain.
c                ó(   >• TR                  S5        g ©Né   rï   ©rt   Úcalleds    €r:   Ú	callback3Ú;DeferredTests.test_reentrantRunCallbacks.<locals>.callback3b  ó   ø€ Ø�M‰M˜!Õr=   c                ó(   >• TR                  S5        g ©Nrá   rï   rc  s    €r:   Ú	callback2Ú;DeferredTests.test_reentrantRunCallbacks.<locals>.callback2e  rg  r=   c                óJ   >• TR                  S5        TR                  T5        g r‡  ©r]   rª   )rt   re  rd  rR   s    €€€r:   Ú	callback1Ú;DeferredTests.test_reentrantRunCallbacks.<locals>.callback1h  s   ø€ Ø�M‰M˜!ÔØ× Ñ  Õ+r=   N)rZ   rá   rb  ©rt   r„   r?   r„   ©r!   rª   rP   r^   )rc   rj  rn  re  rd  rR   s      @@@r:   Útest_reentrantRunCallbacksÚ(DeferredTests.test_reentrantRunCallbacksZ  sa   ú€ ô
 $,£:ˆØˆ÷	÷	÷	,ñ 	,ð 	×Ñ˜YÔ'Ø×Ñ˜YÔ'Ø×Ñ˜$ÔØ×Ñ˜¢Õ+r=   c                ó¶   ^ ^^^• [        5       m/ mSU4S jjmSUUUU 4S jjnTR                  U5        TR                  S5        T R                  TSS/5        g)z€
A callback added to a L{Deferred} by a callback on that L{Deferred}
should not be executed until the running callback returns.
c                ó(   >• TR                  S5        g ri  rï   rc  s    €r:   rj  Ú;DeferredTests.test_nonReentrantCallbacks.<locals>.callback2y  rg  r=   c                óp   >• TR                  S5        TR                  T5        TR                  TS/5        g r‡  )r]   rª   r^   )rt   rj  rd  rR   rc   s    €€€€r:   rn  Ú;DeferredTests.test_nonReentrantCallbacks.<locals>.callback1|  s/   ø€ Ø�M‰M˜!ÔØ× Ñ  Ô+Ø×Ñ˜V a SÕ)r=   NrZ   rá   rp  rq  )rc   rn  rj  rd  rR   s   ` @@@r:   Útest_nonReentrantCallbacksÚ(DeferredTests.test_nonReentrantCallbacksq  sR   û€ ô
 $,£:ˆØˆ÷	÷	*ò 	*ð
 	×Ñ˜YÔ'Ø×Ñ˜$ÔØ×Ñ˜ ! Q Õ(r=   c                óî   ^^^• Sm[        5       mSU4S jjmSUU4S jjnTR                  U5        TR                  S5        U R                  T[        5      nU R                  UR                  T45        g)zÉ
After an exception is raised by a callback which was added to a
L{Deferred} by a callback on that L{Deferred}, the L{Deferred} should
call the first errback with a L{Failure} wrapping that exception.
zcallback raised exceptionc                ó   >• [        T5      er4   )r  )rt   ÚexceptionMessages    €r:   rj  ÚFDeferredTests.test_reentrantRunCallbacksWithFailure.<locals>.callback2Ž  s   ø€ ÜÐ,Ó-Ð-r=   c                ó(   >• TR                  T5        g r4   )rª   )rt   rj  rR   s    €€r:   rn  ÚFDeferredTests.test_reentrantRunCallbacksWithFailure.<locals>.callback1‘  s   ø€ Ø× Ñ  Õ+r=   N©rt   r>   r?   r„   )r!   rª   rP   rg   r  r^   r6   )rc   rn  rd   rj  rR   r}  s      @@@r:   Ú%test_reentrantRunCallbacksWithFailureÚ3DeferredTests.test_reentrantRunCallbacksWithFailure…  si   ú€ ð 7ÐÜ#+£:ˆ÷	.÷	,ð 	,ð 	×Ñ˜YÔ'Ø×Ñ˜$ÔØ×/Ñ/°¼)ÓDˆ	Ø×Ñ˜Ÿ™Ð*:Ð)<Õ=r=   c                óh  ^• [        5       n[        R                  " U5      m[        5       nUR	                  U4S j5        UR                  S5        / nTR	                  UR                  5        U R                  US   5        UR	                  UR                  5        U R                  US   U5        g)zå
If a first L{Deferred} with a result is returned from a callback on a
second L{Deferred}, the result of the second L{Deferred} becomes the
result of the first L{Deferred} and the result of the first L{Deferred}
becomes L{None}.
c                ó   >• T$ r4   rF   ©Úignr«  s    €r:   r  Ú=DeferredTests.test_synchronousImplicitChain.<locals>.<lambda>£  ó   ø€ ¡ur=   Nr   rZ   )	r>   r   rW  r!   rª   rP   r]   r«   rr   )rc   rt   r¨  r²  r«  s       @r:   Útest_synchronousImplicitChainÚ+DeferredTests.test_synchronousImplicitChain™  s‰   ø€ ô “ˆÜ—’˜fÓ%ˆÜ!)£ˆØ×ÑÔ,Ô-Ø�‰˜Ôà*,ˆØ×Ñ˜'Ÿ.™.Ô)Ø×Ñ˜' !™*Ô%Ø×Ñ˜7Ÿ>™>Ô*Ø�‰�g˜a‘j &Õ)r=   c                ó¶  ^• [        5       m[        5       nUR                  U4S j5        UR                  S5        / nTR                  UR                  5        / nUR                  UR                  5        U R	                  U/ 5        U R	                  U/ 5        [        5       nTR                  U5        U R	                  US/5        U R	                  X4/5        g)a  
If a first L{Deferred} without a result is returned from a callback on
a second L{Deferred}, the result of the second L{Deferred} becomes the
result of the first L{Deferred} as soon as the first L{Deferred} has
one and the result of the first L{Deferred} becomes L{None}.
c                ó   >• T$ r4   rF   r†  s    €r:   r  Ú>DeferredTests.test_asynchronousImplicitChain.<locals>.<lambda>µ  r‰  r=   N)r!   rª   rP   r]   r^   r>   )rc   r¨  r  ÚsecondResultrt   r«  s        @r:   Útest_asynchronousImplicitChainÚ,DeferredTests.test_asynchronousImplicitChain¬  sµ   ø€ ô #+£*ˆÜ#+£:ˆØ×ÑÔ,Ô-Ø�‰˜Ôà$&ˆØ×Ñ˜+×,Ñ,Ô-Ø%'ˆØ×Ñ˜<×.Ñ.Ô/à×Ñ˜ bÔ)Ø×Ñ˜ rÔ*ä“ˆØ�‰�vÔà×Ñ˜ t fÔ-Ø×Ñ˜ xÕ0r=   c                ó8  • [         R                  " [        S5      5      nU4SS jjn[        5       nUR	                  U5        UR                  S5        / nUR	                  UR                  5        U R                  US   5        U R                  U[        5        g)zÜ
If a first L{Deferred} with a L{Failure} result is returned from a
callback on a second L{Deferred}, the first L{Deferred}'s result is
converted to L{None} and no unhandled error is logged when it is
garbage collected.
úFirst Deferred's Failurec                ó   • U$ r4   rF   )ro  r«  s     r:   rÖ   Ú<DeferredTests.test_synchronousImplicitErrorChain.<locals>.cbÏ  s   € ØˆLr=   Nr   )ro  r„   r«  rO  r?   rO  )	r   rc  ro   r!   rª   rP   r]   r«   rg   )rc   r«  rÖ   r¨  r  s        r:   Ú"test_synchronousImplicitErrorChainÚ0DeferredTests.test_synchronousImplicitErrorChainÆ  s~   € ô —
’
œ<Ð(BÓCÓDˆà05ö 	ô "*£ˆØ×Ñ˜2ÔØ�‰˜ÔØ"$ˆØ×Ñ˜+×,Ñ,Ô-Ø×Ñ˜+ a™.Ô)Ø×#Ñ# F¬LÕ9r=   c                óN  ^• [        5       m[        5       nUR                  U4S j5        UR                  S5        / nUR                  UR                  5        / nTR                  UR                  5        / nUR                  UR                  5        U R                  U/ 5        U R                  U/ 5        TR                  [        S5      5        U R                  US   R                  [        5      5        U R                  US/5        U R                  [        U5      S5        g)a   
Let C{a} and C{b} be two L{Deferred}s.

If C{a} has no result and is returned from a callback on C{b} then when
C{a} fails, C{b}'s result becomes the L{Failure} that was C{a}'s result,
the result of C{a} becomes L{None} so that no unhandled error is logged
when it is garbage collected.
c                ó   >• T$ r4   rF   r†  s    €r:   r  ÚCDeferredTests.test_asynchronousImplicitErrorChain.<locals>.<lambda>å  r‰  r=   Nr“  r   rZ   )r!   rª   rP   r\   r]   r^   rÆ   ro   r`   ra   r_   )rc   r¨  ÚsecondErrorr  r�  r«  s        @r:   Ú#test_asynchronousImplicitErrorChainÚ1DeferredTests.test_asynchronousImplicitErrorChainÚ  sí   ø€ ô !)£
ˆÜ!)£ˆØ×ÑÔ,Ô-Ø�‰˜ÔØ%'ˆØ×Ñ˜+×,Ñ,Ô-à"$ˆØ×Ñ˜+×,Ñ,Ô-Ø#%ˆØ×Ñ˜<×.Ñ.Ô/à×Ñ˜ bÔ)Ø×Ñ˜ rÔ*à�‰”lÐ#=Ó>Ô?Ø�‰˜ A™×,Ñ,¬\Ó:Ô;Ø×Ñ˜ t fÔ-Ø×Ñœ˜\Ó*¨AÕ.r=   c                ó”  ^^• [        5       m[        5       mTR                  U4S j5        [        5       nUR                  U4S j5        / nUR                  UR                  5        [        5       nTR	                  S5        UR	                  S5        U R                  U/ 5        TR	                  U5        U R                  X#/5        g)z¾
L{Deferred} chaining is transitive.

In other words, let A, B, and C be Deferreds.  If C is returned from a
callback on B and B is returned from a callback on A then when C fires,
A fires.
c                ó   >• T$ r4   rF   r†  s    €r:   r  ÚGDeferredTests.test_doubleAsynchronousImplicitChaining.<locals>.<lambda>  r‰  r=   c                ó   >• T$ r4   rF   )r‡  r¨  s    €r:   r  r     s   ø€ ¡fr=   N)r!   rª   r]   r>   rP   r^   )rc   ÚthirdÚthirdResultrt   r«  r¨  s       @@r:   Ú'test_doubleAsynchronousImplicitChainingÚ5DeferredTests.test_doubleAsynchronousImplicitChaining÷  s    ù€ ô #+£*ˆÜ#+£:ˆØ×ÑÔ,Ô-Ü"*£*ˆØ×ÑÔ,Ô-à$&ˆØ×Ñ˜+×,Ñ,Ô-ä“ˆà�‰˜Ôà�‰�tÔð 	×Ñ˜ bÔ)ð 	�‰�vÔà×Ñ˜ hÕ/r=   c                óº  ^^^• / m/ m[        5       mS	UUU4S jjn[        R                  " S5      R                  U5      R                  TR                  5      nU R                  TSS/5        TR                  S5        TR                  TR                  5        UR                  TR                  5        U R                  / TS5        U R                  T/ SQ5        g)
z 
L{Deferred}s can have callbacks that themselves return L{Deferred}s.
When these "inner" L{Deferred}s fire (even asynchronously), the
callback chain continues.
c                óò   >• TR                  SU 45        [        R                  " S5      nSUU4S jjnSU4S jjnUR                  U5      R                  U5        UR	                  TR                   5        U$ )Nr  r  c                ó*   >• TR                  S5        T$ r  rï   r   s    €€r:   r  ÚXDeferredTests.test_nestedAsynchronousChainedDeferreds.<locals>.cb.<locals>.firstCallback&  s   ø€ Ø—‘Ð9Ô:ð �r=   c                ó4   >• TR                  SU 45        U S-  $ r#  rï   r%  s    €r:   r$  ÚYDeferredTests.test_nestedAsynchronousChainedDeferreds.<locals>.cb.<locals>.secondCallback,  r'  r=   r(  r)  r*  r+  s       €€€r:   rÖ   ÚADeferredTests.test_nestedAsynchronousChainedDeferreds.<locals>.cb"  s_   ø€ Ø�N‰N˜M¨6Ð2Ô3Ü—’˜gÓ&ˆA÷ð ÷"ð �M‰M˜-Ó(×4Ñ4°^ÔDØ�L‰L˜Ÿ™Ô)ØˆHr=   r-  r0  r  r.  ú&Got errbacks but wasn't expecting any.r/  Nr(  ©r!   r   rW  rª   r]   r^   rP   r\   r2  s      @@@r:   Ú'test_nestedAsynchronousChainedDeferredsÚ5DeferredTests.test_nestedAsynchronousChainedDeferreds  sÈ   ú€ ð 68ˆØ"$ˆô  (›zˆ÷	ñ 	ô, �MŠM˜'Ó"×.Ñ.¨rÓ2×>Ñ>¸w¿~¹~ÓNð 	ð
 	×ÑØÐ.Ð0JÐKô	
ð 	�‰�xÔ ð 	×Ñ˜Ÿ™Ô)Ø×Ñ˜Ÿ™Ô)Ø×Ñ˜˜XÐ'OÔPà×ÑØòõ	
r=   c                óÐ  ^^^• / m/ m[        5       mS	UUU4S jjn[        R                  " S5      nUR                  U5        UR                  TR                  5        U R                  TSS/5        TR                  S5        UR                  TR                  5        TR                  TR                  5        U R                  / TS5        U R                  TSSSS/4SS//5        g)
a  
L{Deferred}s can have callbacks that themselves return L{Deferred}s.
These L{Deferred}s can have other callbacks added before they are
returned, which subtly changes the callback chain. When these "inner"
L{Deferred}s fire (even asynchronously), the outer callback chain
continues.
c                óê   >• TR                  SU 45        [        R                  " S5      nSUU4S jjnSU4S jjnUR                  U5      R                  U5      R	                  TR                   5      $ )Nr  r  c                óV   >• TR                  SU 45        SS jnTR                  U5      $ )Nr  c                ó   • U /$ r4   rF   rÇ  s    r:   Ú	transformÚ}DeferredTests.test_nestedAsynchronousChainedDeferredsWithExtraCallbacks.<locals>.cb.<locals>.firstCallback.<locals>.transformm  s	   € Ø"˜8�Or=   )rt   rË   r?   rE  rm  )rt   rµ  r  r²  s     €€r:   r  ÚjDeferredTests.test_nestedAsynchronousChainedDeferredsWithExtraCallbacks.<locals>.cb.<locals>.firstCallbackf  s,   ø€ Ø—‘ °Ð8Ô9ô$ð ×(Ñ(¨Ó3Ð3r=   c                ó4   >• TR                  SU 45        U S-  $ r#  rï   r%  s    €r:   r$  ÚkDeferredTests.test_nestedAsynchronousChainedDeferredsWithExtraCallbacks.<locals>.cb.<locals>.secondCallbackr  r'  r=   )rt   rË   r?   rC  )rt   rE  r?   rE  r*  r+  s       €€€r:   rÖ   ÚSDeferredTests.test_nestedAsynchronousChainedDeferredsWithExtraCallbacks.<locals>.cbb  s\   ø€ Ø�N‰N˜M¨6Ð2Ô3Ü—’˜gÓ&ˆA÷
4ð 
4÷"ð
 —‘˜mÓ,ß‘˜^Ó,ß‘˜HŸO™OÓ,ðr=   r-  r0  r  rM  r­  r$  N)rt   rË   r?   zDeferred[Optional[List[str]]]r®  r2  s      @@@r:   Ú9test_nestedAsynchronousChainedDeferredsWithExtraCallbacksÚGDeferredTests.test_nestedAsynchronousChainedDeferredsWithExtraCallbacksS  sã   ú€ ð  ˆØ"$ˆô  (›zˆ÷	ñ 	ô: —’˜gÓ&ˆØ×Ñ˜"ÔØ×Ñ˜'Ÿ.™.Ô)ð 	×ÑØÐ.Ð0JÐKô	
ð 	�‰�yÔ!ð 	×Ñ˜Ÿ™Ô)Ø×Ñ˜Ÿ™Ô)Ø×Ñ˜˜XÐ'OÔPà×ÑØà(Ø*Ø! I ;Ð/Ø˜IÐ&ð	õ	
r=   c                ó†   • [        5       n[        5       nUR                  U5        U R                  UR                  U5        g)zD
When we chain a L{Deferred}, that chaining is recorded explicitly.
N)r!   ÚchainDeferredrr   Ú
_chainedTo©rc   r;  Úbs      r:   Ú&test_chainDeferredRecordsExplicitChainÚ4DeferredTests.test_chainDeferredRecordsExplicitChain›  s0   € ô %›JˆÜ$›JˆØ	�‰˜ÔØ�‰�a—l‘l AÕ&r=   c                ó¦   • [        5       n[        5       nUR                  U5        UR                  S5        U R                  UR                  5        g)a"  
Any recorded chaining is cleared once the chaining is resolved, since
it no longer exists.

In other words, if one L{Deferred} is recorded as depending on the
result of another, and I{that} L{Deferred} has fired, then the
dependency is resolved and we no longer benefit from recording it.
N)r!   r¾  rP   r«   r¿  rÀ  s      r:   Ú%test_explicitChainClearedWhenResolvedÚ3DeferredTests.test_explicitChainClearedWhenResolved¤  s<   € ô %›JˆÜ$›JˆØ	�‰˜ÔØ	�
‰
�4ÔØ×Ñ˜!Ÿ,™,Õ'r=   c                ó²   ^• [        5       n[        5       mUR                  U4S j5        UR                  S5        U R                  UR                  T5        g)z­
We can chain L{Deferred}s implicitly by adding callbacks that return
L{Deferred}s. When this chaining happens, we record it explicitly as
soon as we can find out about it.
c                ó   >• T$ r4   rF   )rž  rÁ  s    €r:   r  ÚFDeferredTests.test_chainDeferredRecordsImplicitChain.<locals>.<lambda>»  s   ø€ ¡ar=   N)r!   rª   rP   rr   r¿  rÀ  s     @r:   Ú&test_chainDeferredRecordsImplicitChainÚ4DeferredTests.test_chainDeferredRecordsImplicitChain³  s>   ø€ ô %›JˆÜ$›JˆØ	�‰Ô'Ô(Ø	�
‰
�4ÔØ�‰�a—l‘l AÕ&r=   c                ó~  ^• [        5       mS
U4S jjnTR                  U5        TR                  S5        U R                  U/5      nU R	                  [        U5      S5        US   nU R	                  US   [        5        SnU R                  [        R                  " XCS   5      SR                  XCS   5      5        g	)zl
When a Deferred is returned from a callback directly attached to that
same Deferred, a warning is emitted.
c                ó   >• T$ r4   rF   ©rt   rZ  s    €r:   ÚcircularCallbackÚADeferredTests.test_circularChainWarning.<locals>.circularCallbackÆ  ó   ø€ ØˆHr=   ÚfoorZ   r   rº   z1Callback returned the Deferred it was attached tor»   z
Expected match: {!r}
Got: {!r}Nr(  )r!   rª   rP   r½   r^   r_   r¾   r`   ÚreÚsearchr�  )rc   rÏ  Úcircular_warningsÚwarningÚpatternrZ  s        @r:   Útest_circularChainWarningÚ'DeferredTests.test_circularChainWarning¿  s¬   ø€ ô
 $›:ˆ÷	ð 	
�‰Ð&Ô'Ø	�
‰
�5Ôà ×.Ñ.Ð0@Ð/AÓBÐØ×ÑœÐ.Ó/°Ô3Ø# AÑ&ˆØ×Ñ˜ Ñ,Ô.@ÔAØEˆØ�‰Ü�IŠI�g yÑ1Ó2Ø/×6Ñ6°wÈ	Ñ@RÓSõ	
r=   c                ó@  ^• U R                  [        [        S[        R                  5        [        R                  " S[
        S9  [        5       mSU4S jjnTR                  U5        TR                  S5        U R                  T5      nUR                  [
        5        g)z˜
If the deprecation warning for circular deferred callbacks is
configured to be an error, the exception will become the failure
result of the Deferred.
Úfiltersrs   )rº   c                ó   >• T$ r4   rF   rÎ  s    €r:   rÏ  ÚCDeferredTests.test_circularChainException.<locals>.circularCallbackå  rÑ  r=   rÒ  Nr(  )r‘   ÚsetattrrÀ   rÛ  Úfilterwarningsr¾   r!   rª   rP   r'  Útrap)rc   rÏ  ÚfailurerZ  s      @r:   Útest_circularChainExceptionÚ)DeferredTests.test_circularChainExceptionÖ  sz   ø€ ð 	�‰ÜÜØÜ×Ñô		
ô 	×Ò Ô2DÒEÜ#›:ˆ÷	ð 	
�‰Ð&Ô'Ø	�
‰
�5ÔØ×&Ñ& qÓ)ˆØ�‰Ô'Õ(r=   c                ón   • [        5       n[        U5      nU R                  [        U5      SUS S35        g)zh
The C{repr()} of a L{Deferred} contains the class name and a
representation of the internal Python ID.
ú<Deferred at 0xrÑ  Ú>N)r!   Úidr^   Úrepr)rc   rZ  Úaddresss      r:   Ú	test_reprÚDeferredTests.test_reprí  s3   € ô
 %›JˆÜ�Q“%ˆØ×Ñœ˜a› O°G¸A°;¸aÐ"@ÕAr=   c                óŒ   • [        5       nUR                  S5        U R                  [        U5      S[	        U5      S S35        g)zJ
If a L{Deferred} has been fired, then its C{repr()} contains its
result.
r.  rå  rÑ  z current result: 'orange'>N)r!   rP   r^   rè  rç  rx  s     r:   Útest_reprWithResultÚ!DeferredTests.test_reprWithResultö  s;   € ô
 $›:ˆØ	�
‰
�8ÔØ×Ñœ˜a› O´B°q³E¸!°9Ð<VÐ"WÕXr=   c           	     óº   • [        5       n[        5       nUR                  U5        U R                  [        U5      S[	        U5      S S[	        U5      S S35        g)z§
If a L{Deferred} C{a} has been fired, but is waiting on another
L{Deferred} C{b} that appears in its callback chain, then C{repr(a)}
says that it is waiting on C{b}.
rå  rÑ  z waiting on Deferred at 0xræ  N)r!   r¾  r^   rè  rç  rÀ  s      r:   Útest_reprWithChainingÚ#DeferredTests.test_reprWithChainingÿ  sR   € ô %›JˆÜ$›JˆØ	�‰˜ÔØ×ÑÜ�‹GØœb ›e A˜YÐ&@ÄÀAÃÀqÀ	ÈÐKõ	
r=   c                óR   ^ • SU 4S jjnT R                  U" S5      U" S5      5        g)z_
The depth of the call stack does not grow as more L{Deferred} instances
are chained together.
c                ól  >^
^• / mSU4S jjn[        5       n[        U 5       Vs/ s H  n[        5       PM     nnUS S  n[        5       m
UR                  5       nU4     SS jjnUR                  U5        UR                  U5        U(       a9  UR                  5       nU4     SS jjn	UR                  U	5        UnU(       a  M9  UR                  U
4S j5        UR	                  S 5        U H  nUR	                  S 5        M     TR                  T/ 5        T
R	                  S 5        TS   $ s  snf )Nc                ó`   >• TR                  [        [        R                  " 5       5      5        g r4   )r]   r_   Ú	tracebackÚextract_stack)rž  Ústacks    €r:   ÚrecordStackDepthÚVDeferredTests.test_boundedStackDepth.<locals>.chainDeferreds.<locals>.recordStackDepth  s   ø€ Ø—‘œS¤×!8Ò!8Ó!:Ó;Õ<r=   c                ó   • U$ r4   rF   ©rž  r  s     r:   ÚcbInnerÚMDeferredTests.test_boundedStackDepth.<locals>.chainDeferreds.<locals>.cbInner"  s	   € ð �r=   c                ó   • U$ r4   rF   rû  s     r:   Ú
cbNewInnerÚPDeferredTests.test_boundedStackDepth.<locals>.chainDeferreds.<locals>.cbNewInner-  s	   € ð !�Lr=   c                ó   >• T$ r4   rF   )r‡  Úlasts    €r:   r  ÚNDeferredTests.test_boundedStackDepth.<locals>.chainDeferreds.<locals>.<lambda>5  s   ø€ ©$r=   r   ©rž  r>   r?   r„   )rž  r>   r  rO  r?   rO  )r!   ÚrangeÚpoprª   rP   r^   )ÚhowManyrø  Útoprž  ÚinnerDeferredsÚoriginalInnersr  rü  ÚnewInnerrÿ  r  r÷  rc   s             @@€r:   ÚchainDeferredsÚ<DeferredTests.test_boundedStackDepth.<locals>.chainDeferreds  sH  ú€ ØˆE÷=ô #+£*ˆCä*/°¬.ó4Ú*8˜w”–
©.ð ð 4ð ,©AÐ.ˆNÜ#+£:ˆDà"×&Ñ&Ó(ˆEð :?ðØðØ(6ðàõð
 �O‰O˜GÔ$Ø�O‰OÐ,Ô-æ Ø)×-Ñ-Ó/�ð >Fð!Ø#ð!Ø,:ð!à#õ!ð
 ×!Ñ! *Ô-Ø �÷ !�.ð ×ÑÔ.Ô/à�L‰L˜ÔÛ'�Ø—‘˜tÖ$ñ (ð
 ×Ñ˜U BÔ'ð �M‰M˜$ÔØ˜‘8ˆOùòQ4s   ¥D1rZ   rá   N)r  rt  r?   rt  )r^   )rc   r  s   ` r:   Útest_boundedStackDepthÚ$DeferredTests.test_boundedStackDepth  s%   ø€ ÷/	ðf 	×Ñ™¨Ó*©N¸1Ó,=Õ>r=   c                ó^  ^^• [        5       n[        5       m[        5       mUR                  U4S j5        TR                  U4S j5        TR                  S5        UR                  S5        TR                  S5        / nTR                  UR                  5        U R	                  US/5        g)aÆ  
Given three Deferreds, one chained to the next chained to the next,
callbacks on the middle Deferred which are added after the chain is
created are called once the last Deferred fires.

This is more of a regression-style test.  It doesn't exercise any
particular code path through the current implementation of Deferred, but
it does exercise a broken codepath through one of the variations of the
implementation proposed as a resolution to ticket #411.
c                ó   >• T$ r4   rF   r§  s    €r:   r  ÚZDeferredTests.test_resultOfDeferredResultOfDeferredOfFiredDeferredCalled.<locals>.<lambda>V  rª  r=   c                ó   >• T$ r4   rF   )rž  r¢  s    €r:   r  r  W  s   ø€ ©5r=   N)r!   rª   rP   r]   r^   )rc   r«  r²  r¨  r¢  s      @@r:   Ú:test_resultOfDeferredResultOfDeferredOfFiredDeferredCalledÚHDeferredTests.test_resultOfDeferredResultOfDeferredOfFiredDeferredCalledH  s…   ù€ ô !)£
ˆÜ!)£ˆÜ (£
ˆØ×ÑÔ0Ô1Ø×ÑÔ0Ô1Ø�‰˜ÔØ�‰�tÔØ�‰�tÔØ ˆØ×Ñ˜7Ÿ>™>Ô*Ø×Ñ˜ 4 &Õ)r=   c                óŒ  • [         R                  " S5        [        5       n/ n[        S5      n Ue! [         a    UR                  5          Of = fUR                  UR                  5        US   nU R                  UR                  U5        UR                  S   SS u  pVU R                  SU5        U R                  SU5        g)zŸ
C{Deferred.errback()} creates a failure from the current Python
exception.  When Deferred.debug is not set no globals or locals are
captured in that failure.
Fr  r   éþÿÿÿNrF   )r   r’   r!   rD   ÚBaseExceptionrÆ   r\   r]   r^   rb   Úframes©rc   rZ  rY  Úexcrc  ÚlocalzÚglobalzs          r:   Útest_errbackWithNoArgsNoDebugÚ+DeferredTests.test_errbackWithNoArgsNoDebug_  s­   € ô 	×Ò˜5Ô!Ü$›JˆØˆÜ˜6Ó"ˆð	ØˆIøÜó 	Ø�I‰IŽKð	úà	�‰�Q—X‘XÔØ�‰tˆØ×Ñ˜Ÿ™ SÔ)ØŸ+™+ a™.¨¨Ð-‰ˆØ×Ñ˜˜VÔ$Ø×Ñ˜˜WÕ%ó   ¯1 ±AÁAc                óŒ  • [         R                  " S5        [        5       n/ n[        S5      n Ue! [         a    UR                  5          Of = fUR                  UR                  5        US   nU R                  UR                  U5        UR                  S   SS u  pVU R                  / U5        U R                  / U5        g)z™
C{Deferred.errback()} creates a failure from the current Python
exception.  When Deferred.debug is set globals and locals are captured
in that failure.
Tr  r   r  N)r   r’   r!   rD   r  rÆ   r\   r]   r^   rb   r  ÚassertNotEqualr  s          r:   Útest_errbackWithNoArgsÚ$DeferredTests.test_errbackWithNoArgst  s­   € ô 	×Ò˜4Ô Ü$›JˆØˆÜ˜6Ó"ˆð	ØˆIøÜó 	Ø�I‰IŽKð	úà	�‰�Q—X‘XÔØ�‰tˆØ×Ñ˜Ÿ™ SÔ)ØŸ+™+ a™.¨¨Ð-‰ˆØ×Ñ˜B Ô'Ø×Ñ˜B Õ(r   c                óF  • [        5       nUR                  S5        [        R                  " S5        SS jnUR	                  U5        / nUR                  UR                  5        US   nUR                  S   SS u  pVU R                  SU5        U R                  SU5        g)ú„
An error raised by a callback creates a Failure.  The Failure captures
locals and globals if and only if C{Deferred.debug} is set.
NFc                ó   • [        S5      e©Nr  ©rD   ©rž  s    r:   Ú
raiseErrorÚHDeferredTests.test_errorInCallbackDoesNotCaptureVars.<locals>.raiseError’  ó   € Ü˜vÓ&Ð&r=   r   r  rF   r  )	r!   rP   r   r’   rª   r\   r]   r  r^   ©rc   rZ  r+  rY  rc  r  r  s          r:   Ú&test_errorInCallbackDoesNotCaptureVarsÚ4DeferredTests.test_errorInCallbackDoesNotCaptureVars‰  sŒ   € ô
 %›JˆØ	�
‰
�4ÔÜ×Ò˜5Ô!ô	'ð 	
�‰�jÔ!ØˆØ	�‰�Q—X‘XÔØ�‰tˆØŸ+™+ a™.¨¨Ð-‰ˆØ×Ñ˜˜VÔ$Ø×Ñ˜˜WÕ%r=   c                óF  • [        5       nUR                  S5        [        R                  " S5        SS jnUR	                  U5        / nUR                  UR                  5        US   nUR                  S   SS u  pVU R                  / U5        U R                  / U5        g)r&  NTc                ó   • [        S5      er(  r)  r*  s    r:   r+  ÚODeferredTests.test_errorInCallbackCapturesVarsWhenDebugging.<locals>.raiseError¦  r-  r=   r   r  r  )	r!   rP   r   r’   rª   r\   r]   r  r"  r.  s          r:   Ú-test_errorInCallbackCapturesVarsWhenDebuggingÚ;DeferredTests.test_errorInCallbackCapturesVarsWhenDebugging�  sŒ   € ô
 %›JˆØ	�
‰
�4ÔÜ×Ò˜4Ô ô	'ð 	
�‰�jÔ!ØˆØ	�‰�Q—X‘XÔØ�‰tˆØŸ+™+ a™.¨¨Ð-‰ˆØ×Ñ˜B Ô'Ø×Ñ˜B Õ(r=   c                ó´   • SS jn[         R                  " U" 5       5      n[        U[         [           5        U R	                  SU R                  U5      5        g)z=
It can discover the return type of a first level coroutine.
c               “  ó   #   • g7fr‡  rF   rF   r=   r:   Ú
returnsIntÚ4DeferredTests.test_fromCoroutine.<locals>.returnsInt¶  r÷  rø  rZ   Nrù  )r!   r5   r   rt  r^   r/  )rc   r8  rZ  s      r:   Útest_fromCoroutineÚ DeferredTests.test_fromCoroutine±  sD   € ô
	ô ×"Ò"¡:£<Ó0ˆÜ�A”x¤‘}Ô%Ø×Ñ˜˜D×0Ñ0°Ó3Õ4r=   c                ó¢   • S SSU R                   S[        /nU H2  nU R                  [        R                  [        R
                  U5        M4     g)úq
L{Deferred.fromCoroutine} requires a coroutine object or a generator,
and will reject things that are not that.
c                ó   • U $ r4   rF   rÐ  s    r:   r  ÚCDeferredTests.test_fromCoroutineRequiresCoroutine.<locals>.<lambda>Ä  ó   € ‘ar=   rZ   TN©Ú#test_fromCoroutineRequiresCoroutiner   ÚassertRaisesÚNotACoroutineErrorr!   r5   ©rc   ÚthingsThatAreNotCoroutinesÚthings      r:   rB  Ú1DeferredTests.test_fromCoroutineRequiresCoroutine½  óO   € ñ ààà×4Ñ4àäð&
Ð"ó 0ˆEØ×Ñœe×6Ñ6¼×8NÑ8NÐPUÖVò 0r=   úGC works differently on PyPy.c                ó  • [        5       n[        R                  " U5      n[        U5      nX1l        [        R                  " U5      nUR                  S5        AAU R                  U" 5       5        U R                  U" 5       5        g)zd
A circular reference between a `Deferred` and its canceller
is broken when the deferred is called.
N)ÚDummyCancellerÚweakrefÚrefr!   rR   rP   r«   )rc   Ú	cancellerÚweakCancellerrR   ÚweakDeferreds        r:   Ú*test_canceller_circular_reference_callbackÚ8DeferredTests.test_canceller_circular_reference_callbackÔ  sr   € ô #Ó$ˆ	ÜŸš IÓ.ˆô #+¨9Ó"5ˆØ%ÔÜ—{’{ 8Ó,ˆà×Ñ˜$Ôð Øð 	×Ñ™-›/Ô*Ø×Ñ™,›.Õ)r=   c                óZ  • [        5       n[        R                  " U5      n[        U5      nX1l        [        R                  " U5      n[        [        S5      5      nUR                  U5        U R                  U5        AAU R                  U" 5       5        U R                  U" 5       5        g)z`
A circular reference between a `Deferred` and its canceller
is broken when the deferred fails.
úThe test demands failures.N)
rL  rM  rN  r!   rR   r0   r  rÆ   r'  r«   )rc   rO  rP  rR   rQ  rá  s         r:   Ú)test_canceller_circular_reference_errbackÚ7DeferredTests.test_canceller_circular_reference_errbackñ  s�   € ô #Ó$ˆ	ÜŸš IÓ.ˆô #+¨9Ó"5ˆØ%ÔÜ—{’{ 8Ó,ˆäœ)Ð$@ÓAÓBˆØ×Ñ˜Ô!ð 	×Ñ˜XÔ&àØð 	×Ñ™-›/Ô*Ø×Ñ™,›.Õ)r=   c                óÜ   • [        5       n[        R                  " U5      n[        U5      nX1l        UR                  S 5        UR                  S5        AAU R                  U" 5       5        g)z–
A circular reference between a `Deferred` and its canceller is broken
when the deferred is called, even if another deferred gets added to its
chain.
c                ó   • [        5       $ r4   )r!   rn  s    r:   r  ÚKDeferredTests.test_canceller_circular_reference_non_final.<locals>.<lambda>"  s   € ¤x¤zr=   N)rL  rM  rN  r!   rR   rª   rP   r«   )rc   rO  rP  rR   s       r:   Ú+test_canceller_circular_reference_non_finalÚ9DeferredTests.test_canceller_circular_reference_non_final  sa   € ô #Ó$ˆ	ÜŸš IÓ.ˆô #+¨9Ó"5ˆØ%Ôà×ÑÑ1Ô2Ø×Ñ˜$ÔàØð 	×Ñ™-›/Õ*r=   c                óz  • U R                  [        R                  SS [        [        /5         " S S[        [
           5      nU R                  [        R                  S   U5        [        R                  R                  S5        [        R                   H"  nU R                  [        U[        5      5        M$     g)zA
C{_DEFERRED_SUBCLASSES} includes all subclasses of L{Deferred}.
Nrá   c                  ó   • \ rS rSrSrg)Ú2DeferredTests.test_DEFERRED_SUBCLASSES.<locals>.D2i2  rF   NrG   rF   r=   r:   ÚD2r_  2  r  r=   r`  éÿÿÿÿ)	r^   r   Ú_DEFERRED_SUBCLASSESr!   r#   rt  r  r`   rý   )rc   r`  Úklasss      r:   Útest_DEFERRED_SUBCLASSESÚ&DeferredTests.test_DEFERRED_SUBCLASSES,  sŒ   € ð 	×Ñœ×3Ñ3°B°QÐ7¼(ÄLÐ9QÔRô	”œ#‘ô 	ð 	×Ñœ×3Ñ3°BÑ7¸Ô<Ü×"Ñ"×&Ñ& rÔ*ô ×/Ô/ˆEØ�O‰OœJ u¬hÓ7Ö8ò 0r=   )r�   rŽ   r�   Nr‰   )r6   r>   r7   r>   r?   r   ©r6   r>   r7   r>   r?   r„   )r6   r0   r7   r>   r?   r„   )^rH   rI   rJ   rK   r•   r›   rŸ   r£   r­   r±   r´   r·   rÁ   rÈ   rÌ   rÏ   rë   rõ   r  r  r  r  r"  r,  r2  r5  r8  r<  r?  rE  rM  rP  rS  r[  r_  rd  ri  ru  ry  rƒ  rŽ  rš  r£  r¬  r³  r»  r¿  rÃ  rË  rÖ  rÝ  rä  rë  rð  rû  r
  r  r3  rP  r]  rr  ry  r‚  rŠ  r�  r–  rœ  r¤  r¯  r»  rÂ  rÅ  rÊ  rØ  râ  rê  rí  rð  r  r  r  r#  r/  r4  r:  rB  ÚpyunitÚskipIfr.   rR  rV  r[  rd  rL   rF   r=   r:   r‹   r‹   ¦   s  † ôBôô-ô+ôAôIôQôBô

ô5ôAô"5ô,"
ôH%ô('.ôR?ô"?ô"&ô&ô"
@ôBô$
@ô9ôKô:ô"+ô )ô.)ô=ô)ô2ô2ô2ô
=ôô
ô6
ô<3ô,-ô()ô &ô >ô(Kô?ô1ô(ô >ô"2ô$
.ô	6ôEôDô2
ô.*
ôX%
ôN-
ô^,ô.)ô(>ô(*ô&1ô4:ô(/ô:0ô>;
ôzF
ôP'ô(ô
'ô
ô.)ô.BôYô
ô9?ôv*ô.&ô*)ô*&ô()ô(
5ôWð. ‡]‚]�5Ð9Ó:ó*ó ;ð*ð8 ‡]‚]�5Ð9Ó:ó*ó ;ð*ð> ‡]‚]�5Ð9Ó:ó+ó ;ð+÷49r=   r‹   c                  ó2   • \ rS rSr% SrSrS\S'   SS jrSrg)	rL  i>  zv
A callable that does nothing.
It is intended to be used just to get an object reference
to support GC related tests.
NzOptional[Deferred[Any]]rR   c                ó   • g)zF
This is not expected to be called as part of the current test suite.
NrF   r¬   s     r:   Ú__call__ÚDummyCanceller.__call__G  s   � r=   rF   )rR   ri   r?   r„   )	rH   rI   rJ   rK   rj   rR   Ú__annotations__rk  rL   rF   r=   r:   rL  rL  >  s   ‡ ñð )-€HÐ%Ó,÷r=   rL  c                ó†   ^• S/U -  m/ n[        U 5       H&  nU4SU4S jjjnUR                  [        US95        M(     TU4$ )z´
Create a list of Deferreds and a corresponding list of integers
tracking how many times each Deferred has been cancelled.  Without
additional steps the Deferreds will never fire.
r   c                ó    >• TU==   S-  ss'   g r‡  rF   )rZ  ÚnÚcancelledStates     €r:   r&  Ú_setupRaceState.<locals>.cancelX  s   ø€ Ø˜1Ó Ñ"Ôr=   ©rO  )rZ  rL  rp  rt  r?   r„   )r  r]   r!   )ÚnumDeferredsÚdsrp  r&  rq  s       @r:   Ú_setupRaceStaterv  M  sR   ø€ ð �S˜<Ñ'€Nà!#€BÜ�<Ö ˆà12÷ 	#ñ 	#ð 	�	‰	”( VÑ,Ö-ñ !ð ˜2ÐÐr=   c                  óÞ   • \ rS rSrSr\" \" SSS9\" SSS9S9SS j5       r\" \" SSS9\" SSS9S9SS j5       r\" \" SSS9\" SSS9S9SS	 j5       r	SS
 jr
\" \" SSS9S9SS j5       rSrg)Ú	RaceTestsi`  z
Tests for L{race}.
r   rb  )Ú	min_valueÚ	max_value)ÚbeforeWinnerÚafterWinnerc                ó  • [        US-   U-   5      u  p4[        U5      n[        5       nXA   R                  U5        [	        U R                  U5      [        X45      5        S/U-  S/-   S/U-  -   n[	        U[        U5      5        g)aÉ  
When one of the L{Deferred}s passed to L{race} fires successfully,
the L{Deferred} return by L{race} fires with the index of that
L{Deferred} and its result and cancels the rest of the L{Deferred}s.

@param beforeWinner: A randomly selected number of Deferreds to
    appear before the "winning" Deferred in the list passed in.

@param beforeWinner: A randomly selected number of Deferreds to
    appear after the "winning" Deferred in the list passed in.
rZ   r   N)rv  r+   r>   rP   r   r/  r   )rc   r{  r|  rq  ru  Ú
raceResultr¡  ÚexpectedCancelledStates           r:   Útest_successÚRaceTests.test_successe  s•   € ô  -¨\¸AÑ-=ÀÑ-KÓLÑˆä˜"“Xˆ
Ü“8ˆØ
Ñ×!Ñ! (Ô+ô 	Ø× Ñ  Ó,Ü�lÐ-Ó.ô	
ð
 #$  |Ñ!3°q°cÑ!9¸Q¸CÀ+Ñ<MÑ!MÐÜØÜÐ+Ó,õ	
r=   c           	     óx  • [        US-   U-   5      u  p4[        [        S5      5      n[        U5      nU H  nUR	                  U5        M     U R                  U[        5      n[        UR                  R                  [        U/[        U5      -  5      5        [        U[        S/[        U5      -  5      5        g)a¢  
When all of the L{Deferred}s passed to L{race} fire with failures,
the L{Deferred} return by L{race} fires with L{FailureGroup} wrapping
all of their failures.

@param beforeWinner: A randomly selected number of Deferreds to
    appear before the "winning" Deferred in the list passed in.

@param beforeWinner: A randomly selected number of Deferreds to
    appear after the "winning" Deferred in the list passed in.
rZ   rU  r   N)rv  r0   r  r+   rÆ   r'  r'   r   rb   rf   r   r_   )	rc   r{  r|  rq  ru  rá  r~  rZ  ÚactualFailures	            r:   Útest_failureÚRaceTests.test_failureˆ  s§   € ô  -¨\¸AÑ-=ÀÑ-KÓLÑˆäœ)Ð$@ÓAÓBˆÜ˜"“Xˆ
ÛˆAØ�I‰I�gÖñ ð ×,Ñ,¨Z¼ÓFˆÜØ×Ñ×(Ñ(Ü�g�Y¤ R£Ñ(Ó)ô	
ô 	ØÜ�a�Sœ3˜r›7‘]Ó#õ	
r=   c                ó.  • [        US-   U-   5       Vs/ s H  n[        5       PM     nn[        U5      nXA   R                  S5        XAS-      R                  S5        U R	                  U5        [        U R                  5       [        5       5        gs  snf )zŠ
If one of the Deferreds fires after it was cancelled its result
goes nowhere.  In particular, it does not cause any errors to be
logged.
rá   NrZ   )r  r!   r+   rP   r/  r   rq   r   )rc   r{  r|  rp  ru  r~  s         r:   Útest_resultAfterCancelÚ RaceTests.test_resultAfterCancel©  sŒ   € ô !& l°QÑ&6¸Ñ&DÔ Eó$
Ú E˜1ŒHŽJÑ Eð 	ð $
ô ˜"“Xˆ
Ø
Ñ×!Ñ! $Ô'Ø
˜!ÑÑ×%Ñ% dÔ+à×Ñ˜ZÔ(Ü�D×*Ñ*Ó,¬e«gÕ6ùò$
s   ”Bc                óÈ   • [        5       nU[        S S9/n[        5       n[        U5      nUR                  U5        [	        U R                  U5      [        SU45      5        g)zf
If one of the input Deferreds has a cancel function that fires it
with success, nothing bad happens.
c                ó4   • U R                  [        5       5      $ r4   )rP   r>   ©rZ  s    r:   r  Ú1RaceTests.test_resultFromCancel.<locals>.<lambda>È  s   € ¨¯©´F³HÔ)=r=   rs  r   N)r!   r>   r+   rP   r   r/  r   )rc   Úwinnerru  r¡  r~  s        r:   Útest_resultFromCancelÚRaceTests.test_resultFromCancelÀ  sZ   € ô
 $,£:ˆàÜÑ=Ñ>ð&
ˆô “8ˆÜ˜"“Xˆ
Ø�‰˜Ô!ä�D×(Ñ(¨Ó4´hÀÀ8¸}Ó6MÕNr=   rZ   )rt  c                ó²   • [        U5      u  p#[        U5      nUR                  5         [        U[	        S/U-  5      5        U R                  U[        5        g)z]
If the result of L{race} is cancelled then all of the L{Deferred}s
passed in are cancelled.
rZ   N)rv  r+   r&  r   r   r'  r'   )rc   rt  rq  ru  r~  s        r:   Útest_cancelÚRaceTests.test_cancelÐ  sL   € ô -¨\Ó:Ñˆä˜"“Xˆ
Ø×ÑÔä�N¤H¨a¨S°<Ñ-?Ó$@ÔAØ×Ñ˜Z¬Õ6r=   rF   N)r{  rt  r|  rt  r?   r„   r‰   )rt  rt  r?   r„   )rH   rI   rJ   rK   rj   r   r   r€  r„  r‡  rŽ  r‘  rL   rF   r=   r:   rx  rx  `  s·   † ññ Ù¨°QÑ7Ù q°AÑ6ñó
ó	ð
ñ> Ù¨°QÑ7Ù q°AÑ6ñó
ó	ð
ñ: Ù¨°QÑ7Ù q°AÑ6ñó7ó	ð7ô&Oñ  Ù¨°QÑ7ñó7óó7r=   rx  c                  ó6   • \ rS rSrSrSS jrSS jrSS jrSrg)	ÚFirstErrorTestsiá  z
Tests for L{FirstError}.
c                óÒ   • [        S5      n Ue! [         a    [        5       n Of = f[        R                  " US5      nU R                  [        U5      S[        U5       S35        g)zŽ
The repr of a L{FirstError} instance includes the repr of the value of
the sub-failure and the index which corresponds to the L{FirstError}.
ú	some textrb  zFirstError[#3, Ú]N)r™  r  r0   r   rÿ   r^   rè  ©rc   r  r9   rs   s       r:   rê  ÚFirstErrorTests.test_repræ  sc   € ô
 ˜Ó%ˆð	ØˆIøÜó 	Ü“	ŠAð	úô × Ò   AÓ&ˆØ×Ñœ˜e›¨¼¸S»	°{À!Ð&DÕEó   � �&¥&c                óÒ   • [        S5      n Ue! [         a    [        5       n Of = f[        R                  " US5      nU R                  [        U5      S[        U5       S35        g)z
The str of a L{FirstError} instance includes the str of the
sub-failure and the index which corresponds to the L{FirstError}.
r–  rÏ  zFirstError[#5, r—  N)r™  r  r0   r   rÿ   r^   rË   r˜  s       r:   Útest_strÚFirstErrorTests.test_strô  sc   € ô
 ˜Ó%ˆð	ØˆIøÜó 	Ü“	ŠAð	úô × Ò   AÓ&ˆØ×Ñœ˜U› ´s¸1³v°h¸aÐ%@ÕArš  c                óÚ  •  SS-    [        R                  " WS5      n[        R                  " US5      n [	        S5      e! [          a    [        5       n NPf = f! [          a    [        5       n Of = f[        R                  " US5      nU R                  X#:H  5        U R                  X%:H  5        U R                  X%:g  5        U R                  X#:g  5        U R                  US:H  5        g)z¶
L{FirstError} instances compare equal to each other if and only if
their failure and index compare equal.  L{FirstError} instances do not
compare equal to instances of other types.
rZ   r   é   Úbaré	   rÔ  N)r  r0   r   rÿ   r™  r`   r0  )rc   ÚfirstFailureÚoneÚ
anotherOneÚsecondFailureÚanothers         r:   Útest_comparisonÚFirstErrorTests.test_comparison  s×   € ð	%Ø�ŠFô ×Ò˜|¨RÓ0ˆÜ×%Ò% l°BÓ7ˆ
ð	&Ü˜UÓ#Ð#øô ó 	%Ü"›9ŠLð	%ûô ó 	&Ü#›IŠMð	&úô ×"Ò" =°!Ó4ˆà�‰˜Ñ)Ô*Ø×Ñ˜™Ô(Ø�‰˜™Ô'Ø×Ñ˜Ñ*Ô+à×Ñ˜ ™Õ#s"   ‚A ¶A ÁAÁAÁA2Á1A2rF   Nr‰   )	rH   rI   rJ   rK   rj   rê  rœ  r§  rL   rF   r=   r:   r”  r”  á  s   † ñôFôB÷$r=   r”  c                  óÜ   • \ rS rSrSS jrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)ÚAlreadyCalledTestsi  c                ód   • [         R                  " 5       U l        [         R                  " S5        g ©NT)r   r“   Ú_deferredWasDebuggingr’   r”   s    r:   r•   ÚAlreadyCalledTests.setUp   s!   € Ü%*×%7Ò%7Ó%9ˆÔ"Ü×Ò˜4Õ r=   c                óD   • [         R                  " U R                  5        g r4   )r   r’   r­  r”   s    r:   ÚtearDownÚAlreadyCalledTests.tearDown$  s   € Ü×Ò˜4×5Ñ5Õ6r=   c                ó   • g r4   rF   rš   s      r:   r›   ÚAlreadyCalledTests._callback'  ó   € Ør=   c                ó   • g r4   rF   rš   s      r:   r£   ÚAlreadyCalledTests._errback*  r´  r=   c                ó&   • UR                  S5        g )Nr§   rO   rx  s     r:   Ú_call_1ÚAlreadyCalledTests._call_1-  ó   € Ø	�
‰
�7Õr=   c                ó&   • UR                  S5        g )NÚtwicerO   rx  s     r:   Ú_call_2ÚAlreadyCalledTests._call_20  rº  r=   c                óH   • UR                  [        [        5       5      5        g r4   ©rÆ   r0   ro   rx  s     r:   Ú_err_1ÚAlreadyCalledTests._err_13  ó   € Ø	�	‰	”'œ,›.Ó)Õ*r=   c                óH   • UR                  [        [        5       5      5        g r4   rÀ  rx  s     r:   Ú_err_2ÚAlreadyCalledTests._err_26  rÃ  r=   c                óÜ   • [        5       nUR                  U R                  U R                  5        U R	                  U5        U R                  [        R                  U R                  U5        g r4   )	r!   rÅ   r›   r£   r¸  rC  r   ÚAlreadyCalledErrorr½  rx  s     r:   ÚtestAlreadyCalled_CCÚ'AlreadyCalledTests.testAlreadyCalled_CC9  sF   € Ü#›:ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø�‰�QŒØ×Ñœ%×2Ñ2°D·L±LÀ!ÕDr=   c                óÜ   • [        5       nUR                  U R                  U R                  5        U R	                  U5        U R                  [        R                  U R                  U5        g r4   )	r!   rÅ   r›   r£   r¸  rC  r   rÈ  rÅ  rx  s     r:   ÚtestAlreadyCalled_CEÚ'AlreadyCalledTests.testAlreadyCalled_CE?  sF   € Ü#›:ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø�‰�QŒØ×Ñœ%×2Ñ2°D·K±KÀÕCr=   c                óÜ   • [        5       nUR                  U R                  U R                  5        U R	                  U5        U R                  [        R                  U R                  U5        g r4   )	r!   rÅ   r›   r£   rÁ  rC  r   rÈ  rÅ  rx  s     r:   ÚtestAlreadyCalled_EEÚ'AlreadyCalledTests.testAlreadyCalled_EEE  sF   € Ü#›:ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø�‰�AŒØ×Ñœ%×2Ñ2°D·K±KÀÕCr=   c                óÜ   • [        5       nUR                  U R                  U R                  5        U R	                  U5        U R                  [        R                  U R                  U5        g r4   )	r!   rÅ   r›   r£   rÁ  rC  r   rÈ  r½  rx  s     r:   ÚtestAlreadyCalled_ECÚ'AlreadyCalledTests.testAlreadyCalled_ECK  sF   € Ü#›:ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø�‰�AŒØ×Ñœ%×2Ñ2°D·L±LÀ!ÕDr=   c                ó¶   • SnU H>  nUR                  SU-  5      (       d  M  UR                  SU-  5      (       d  M9  US-  nM@     U R                  XT:H  5        g )Nr   z %s:z %srZ   )r†   Úendswithr`   )rc   ÚlinetypeÚfuncÚlinesr¡  ÚcountÚlines          r:   Ú_countÚAlreadyCalledTests._countQ  sQ   € ØˆÛˆDØ�‰˜v¨Ñ0×1Ó1°d·m±mÀEÈDÁL×6QÓ6QØ˜‘
’ñ ð 	�‰˜Ñ)Õ*r=   c                óR  • UR                   S   R                  S5      nU R                  SX%S5        U R                  SSUS5        U R                  SSUS5        U R                  SSUS5        U R                  SSUS5        U R                  S	X5S5        U R                  S	XES5        g )
Nr   Ú
ÚCrZ   r¸  r½  rÁ  rÅ  ÚI)r6   ÚsplitrÛ  )rc   r  ÚcallerÚinvoker1Úinvoker2rØ  s         r:   Ú_checkÚAlreadyCalledTests._checkX  s’   € à—‘�q‘	—‘ Ó%ˆð 	�‰�C˜¨Ô*Ø�‰�C˜ E¨1Ô-Ø�‰�C˜ E¨1Ô-Ø�‰�C˜ 5¨!Ô,Ø�‰�C˜ 5¨!Ô,à�‰�C˜¨!Ô,Ø�‰�C˜¨!Õ,r=   c                ó6  • [        5       nUR                  U R                  U R                  5        U R	                  U5         U R                  U5        U R                  S5        g ! [        R                   a  nU R                  USSS5         S nAg S nAff = f)Nú2second callback failed to raise AlreadyCalledErrorÚtestAlreadyCalledDebug_CCr¸  r½  )
r!   rÅ   r›   r£   r¸  r½  rc  r   rÈ  rå  ©rc   rZ  r  s      r:   ré  Ú,AlreadyCalledTests.testAlreadyCalledDebug_CCf  sz   € Ü#›:ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø�‰�QŒð	LØ�L‰L˜ŒOð �I‰IÐJÕKøô ×'Ñ'ó 	NØ�K‰K˜Ð6¸	À9×MÑMûð	Núó   ÁA& Á&BÁ:BÂBc                ó6  • [        5       nUR                  U R                  U R                  5        U R	                  U5         U R                  U5        U R                  S5        g ! [        R                   a  nU R                  USSS5         S nAg S nAff = f)Nú1second errback failed to raise AlreadyCalledErrorÚtestAlreadyCalledDebug_CEr¸  rÅ  )
r!   rÅ   r›   r£   r¸  rÅ  rc  r   rÈ  rå  rê  s      r:   rï  Ú,AlreadyCalledTests.testAlreadyCalledDebug_CEq  sz   € Ü#›:ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø�‰�QŒð	KØ�K‰K˜ŒNð �I‰IÐIÕJøô ×'Ñ'ó 	MØ�K‰K˜Ð6¸	À8×LÑLûð	Múrì  c                ó6  • [        5       nUR                  U R                  U R                  5        U R	                  U5         U R                  U5        U R                  S5        g ! [        R                   a  nU R                  USSS5         S nAg S nAff = f)Nrè  ÚtestAlreadyCalledDebug_ECrÁ  r½  )
r!   rÅ   r›   r£   rÁ  r½  rc  r   rÈ  rå  rê  s      r:   rò  Ú,AlreadyCalledTests.testAlreadyCalledDebug_EC|  sz   € Ü#›:ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø�‰�AŒð	LØ�L‰L˜ŒOð �I‰IÐJÕKøô ×'Ñ'ó 	MØ�K‰K˜Ð6¸À)×LÑLûð	Múrì  c                ó6  • [        5       nUR                  U R                  U R                  5        U R	                  U5         U R                  U5        U R                  S5        g ! [        R                   a  nU R                  USSS5         S nAg S nAff = f)Nrî  ÚtestAlreadyCalledDebug_EErÁ  rÅ  )
r!   rÅ   r›   r£   rÁ  rÅ  rc  r   rÈ  rå  rê  s      r:   rõ  Ú,AlreadyCalledTests.testAlreadyCalledDebug_EE‡  sz   € Ü#›:ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø�‰�AŒð	KØ�K‰K˜ŒNð �I‰IÐIÕJøô ×'Ñ'ó 	LØ�K‰K˜Ð6¸À(×KÑKûð	Lúrì  c                óp  • [         R                  " S5        [        5       nUR                  U R                  U R
                  5        U R                  U5         U R                  U5        U R                  S5        g ! [         R                   a%  nU R                  UR                  5         S nAg S nAff = f)NFrè  )r   r’   r!   rÅ   r›   r£   r¸  r½  rc  rÈ  r0  r6   rê  s      r:   ÚtestNoDebuggingÚ"AlreadyCalledTests.testNoDebugging’  s…   € Ü×Ò˜5Ô!Ü#›:ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø�‰�QŒð	LØ�L‰L˜ŒOð �I‰IÐJÕKøô ×'Ñ'ó 	%Ø×Ñ˜QŸV™V×$Ñ$ûð	%ús   ÁA< Á<B5ÂB0Â0B5c                óh  • [         R                  " S5        [        5       nUR                  S 5        [         R                  " S5        UR	                  S 5        [         R                  " S5        [        5       nUR	                  S 5        [         R                  " S5        UR                  S 5        g )NFc                ó   • g r4   rF   ©r‡  s    r:   r  Ú8AlreadyCalledTests.testSwitchDebugging.<locals>.<lambda>£  ó   € ˜dr=   Tc                ó   • g r4   rF   rü  s    r:   r  rý  «  rþ  r=   )r   r’   r!   ÚaddBothrP   rx  s     r:   ÚtestSwitchDebuggingÚ&AlreadyCalledTests.testSwitchDebuggingž  s|   € ô 	×Ò˜5Ô!Ü$›JˆØ	�	‰	Ñ"Ô#Ü×Ò˜4Ô Ø	�
‰
�4Ôä×Ò˜5Ô!Ü‹JˆØ	�
‰
�4ÔÜ×Ò˜4Ô Ø	�	‰	Ñ"Õ#r=   )r­  Nr‰   rf  )rZ  r˜  r?   r„   )
rÖ  rË   r×  rË   rØ  rE  r¡  rt  r?   r„   )
r  r  râ  rË   rã  rË   rä  rË   r?   r„   )rH   rI   rJ   rK   r•   r°  r›   r£   r¸  r½  rÁ  rÅ  rÉ  rÌ  rÏ  rÒ  rÛ  rå  ré  rï  rò  rõ  rø  r  rL   rF   r=   r:   rª  rª    so   † ô!ô7ôôôôô+ô+ôEôDôDôEô+ô-ô	Lô	Kô	Lô	Kô
L÷$r=   rª  c                  óÒ   • \ rS rSrSS jrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)ÚDeferredCancellerTestsi®  c                ó<   • S U l         S U l        S U l        SU l        g r˜   )rŽ   r�   r�   ÚcancellerCallCountr”   s    r:   r•   ÚDeferredCancellerTests.setUp¯  s"   € Ø.2ˆÔØ15ˆÔØ/3ˆÔØ"#ˆÕr=   c                ó<   • U R                  U R                  S5        g )Nr¶  )r¿   r  r”   s    r:   r°  ÚDeferredCancellerTests.tearDownµ  s   € à�‰�d×-Ñ-¨vÕ6r=   c                ó   • Xl         U$ r4   r™   ©rc   Údatas     r:   r›   Ú DeferredCancellerTests._callback¹  s   € Ø#ÔØˆr=   c                ó   • Xl         g r4   rž   r  s     r:   rŸ   Ú!DeferredCancellerTests._callback2½  s   € Ø $Õr=   c                ó   • Xl         g r4   r¢   )rc   rs   s     r:   r£   ÚDeferredCancellerTests._errbackÀ  s   € Ø#Õr=   c                ó@  • [        5       nUR                  U R                  U R                  5        UR	                  5         U R
                  c   eU R                  U R
                  R                  [        R                  5        U R                  U R                  5        g)za
A L{Deferred} without a canceller must errback with a
L{defer.CancelledError} and not callback.
N)r!   rÅ   r›   r£   r&  r�   r^   rþ   r   r   r«   rŽ   rx  s     r:   Útest_noCancellerÚ'DeferredCancellerTests.test_noCancellerÃ  sr   € ô
 %›JˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�‰Œ
Ø×"Ñ"Ñ.Ð.Ð.Ø×Ñ˜×,Ñ,×1Ñ1´5×3GÑ3GÔHØ×Ñ˜$×.Ñ.Õ/r=   c                ób  • [        5       nUR                  U R                  U R                  5        UR	                  5         UR                  S5        U R                  [        R                  UR
                  S5        U R                  [        R                  UR                  [        5       5        g)z¬
A L{Deferred} without a canceller, when cancelled must allow
a single extra call to callback, and raise
L{defer.AlreadyCalledError} if callbacked or errbacked thereafter.
N)r!   rÅ   r›   r£   r&  rP   rC  r   rÈ  rÆ   r  rx  s     r:   Ú!test_raisesAfterCancelAndCallbackÚ8DeferredCancellerTests.test_raisesAfterCancelAndCallbackÏ  st   € ô %›JˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�‰Œ
ð 	
�
‰
�4Ôð 	×Ñœ%×2Ñ2°A·J±JÀÔEØ×Ñœ%×2Ñ2°A·I±I¼y»{ÕKr=   c                ór  • [        5       nUR                  U R                  U R                  5        UR	                  5         UR                  [        5       5        U R                  [        R                  UR                  S5        U R                  [        R                  UR
                  [        5       5        g)z«
A L{Deferred} without a canceller, when cancelled must allow
a single extra call to errback, and raise
L{defer.AlreadyCalledError} if callbacked or errbacked thereafter.
N)r!   rÅ   r›   r£   r&  rÆ   r  rC  r   rÈ  rP   rx  s     r:   Ú test_raisesAfterCancelAndErrbackÚ7DeferredCancellerTests.test_raisesAfterCancelAndErrbackà  sv   € ô %›JˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�‰Œ
ð 	
�	‰	”)“+Ôð 	×Ñœ%×2Ñ2°A·J±JÀÔEØ×Ñœ%×2Ñ2°A·I±I¼y»{ÕKr=   c                ó  • [        5       nUR                  U R                  U R                  5        UR	                  5         U R
                  nUR                  S5        UR	                  5         U R                  X R
                  5        g)zm
A L{Deferred} without a canceller, when cancelled and then
callbacked, ignores multiple cancels thereafter.
N)r!   rÅ   r›   r£   r&  r�   rP   rr   ©rc   rZ  ÚcurrentFailures      r:   Ú5test_noCancellerMultipleCancelsAfterCancelAndCallbackÚLDeferredCancellerTests.test_noCancellerMultipleCancelsAfterCancelAndCallbackñ  s\   € ô
 %›JˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�‰Œ
Ø×,Ñ,ˆà	�
‰
�4Ôà	�‰Œ
Ø�‰�n×&9Ñ&9Õ:r=   c                ó  • [        5       nUR                  U R                  U R                  5        UR	                  5         U R
                  c   eU R                  U R
                  R                  [        R                  5        U R
                  nUR                  [        5       5        U R                  U R
                  R                  [        R                  5        UR	                  5         U R                  X R
                  5        g)zl
A L{Deferred} without a canceller, when cancelled and then
errbacked, ignores multiple cancels thereafter.
N)r!   rÅ   r›   r£   r&  r�   r^   rþ   r   r   rÆ   rD   rr   r  s      r:   Ú4test_noCancellerMultipleCancelsAfterCancelAndErrbackÚKDeferredCancellerTests.test_noCancellerMultipleCancelsAfterCancelAndErrback 	  s´   € ô
 %›JˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�‰Œ
Ø×"Ñ"Ñ.Ð.Ð.Ø×Ñ˜×,Ñ,×1Ñ1´5×3GÑ3GÔHØ×,Ñ,ˆà	�	‰	”,“.Ô!à×Ñ˜×,Ñ,×1Ñ1´5×3GÑ3GÔHØ	�‰Œ
Ø�‰�n×&9Ñ&9Õ:r=   c                óx  • [        5       nUR                  U R                  U R                  5        UR	                  5         U R
                  c   eU R                  U R
                  R                  [        R                  5        U R
                  nUR	                  5         U R                  X R
                  5        g)z—
Calling cancel multiple times on a deferred with no canceller
results in a L{defer.CancelledError}. Subsequent calls to cancel
do not cause an error.
N)r!   rÅ   r›   r£   r&  r�   r^   rþ   r   r   rr   r  s      r:   Útest_noCancellerMultipleCancelÚ5DeferredCancellerTests.test_noCancellerMultipleCancel	  s„   € ô %›JˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�‰Œ
Ø×"Ñ"Ñ.Ð.Ð.Ø×Ñ˜×,Ñ,×1Ñ1´5×3GÑ3GÔHØ×,Ñ,ˆØ	�‰Œ
Ø�‰�n×&9Ñ&9Õ:r=   c                óÂ  ^ • SU 4S jjn[        US9nUR                  T R                  T R                  5        UR	                  5         T R
                  c   eT R                  T R
                  R                  [        R                  5        T R
                  nUR	                  5         T R                  UT R
                  5        T R                  T R                  S5        g)zü
Verify that calling cancel multiple times on a deferred with a
canceller that does not errback results in a
L{defer.CancelledError} and that subsequent calls to cancel do not
cause an error and that after all that, the canceller was only
called once.
c                ó0   >• T=R                   S-  sl         g r‡  ©r  ©rZ  rc   s    €r:   r&  ÚCDeferredCancellerTests.test_cancellerMultipleCancel.<locals>.cancel*	  ó   ø€ Ø×#Ò# qÑ(Ö#r=   rs  NrZ   ©rZ  rL  r?   r„   )r!   rÅ   r›   r£   r&  r�   r^   rþ   r   r   rr   r  )rc   r&  rZ  r  s   `   r:   Útest_cancellerMultipleCancelÚ3DeferredCancellerTests.test_cancellerMultipleCancel!	  s¥   ø€ ÷	)ô %¨vÑ6ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�‰Œ
Ø×"Ñ"Ñ.Ð.Ð.Ø×Ñ˜×,Ñ,×1Ñ1´5×3GÑ3GÔHØ×,Ñ,ˆØ	�‰Œ
Ø�‰�n d×&9Ñ&9Ô:Ø×Ñ˜×0Ñ0°!Õ4r=   c                ó  ^ • SU 4S jjn[        US9nUR                  T R                  T R                  5        UR	                  5         T R                  T R                  S5        T R                  c   eT R                  T R                  R                  [        R                  5        T R                  [        R                  UR                  S5        T R                  [        R                  UR                  [        5       5        g)z‘
Verify that a L{Deferred} calls its specified canceller when
it is cancelled, and that further call/errbacks raise
L{defer.AlreadyCalledError}.
c                ó0   >• T=R                   S-  sl         g r‡  r(  r)  s    €r:   r&  Ú;DeferredCancellerTests.test_simpleCanceller.<locals>.cancel>	  r+  r=   rs  rZ   Nr,  )r!   rÅ   r›   r£   r&  r^   r  r�   rþ   r   r   rC  rÈ  rP   rÆ   r  ©rc   r&  rZ  s   `  r:   Útest_simpleCancellerÚ+DeferredCancellerTests.test_simpleCanceller7	  s¹   ø€ ÷	)ô %¨vÑ6ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�‰Œ
Ø×Ñ˜×0Ñ0°!Ô4Ø×"Ñ"Ñ.Ð.Ð.Ø×Ñ˜×,Ñ,×1Ñ1´5×3GÑ3GÔHð 	×Ñœ%×2Ñ2°A·J±JÀÔEØ×Ñœ%×2Ñ2°A·I±I¼y»{ÕKr=   c                ó˜   ^ ^• SUU 4S jjn[        US9mTR                  T R                  T R                  5        TR	                  5         g)zA
Verify that a canceller is given the correct deferred argument.
c                ó*   >• TR                  U T5        g r4   )rr   )r	  rZ  rc   s    €€r:   r&  Ú8DeferredCancellerTests.test_cancellerArg.<locals>.cancelQ	  s   ø€ Ø�M‰M˜"˜aÕ r=   rs  N)r	  rL  r?   r„   )r!   rÅ   r›   r£   r&  r2  s   ` @r:   Útest_cancellerArgÚ(DeferredCancellerTests.test_cancellerArgL	  s8   ù€ ÷
	!ð 	!ô %¨vÑ6ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�‰�
r=   c                ó\  ^ • SU 4S jjn[        US9nUR                  T R                  T R                  5        UR	                  S5        UR                  5         T R                  T R                  S5        T R                  T R                  5        T R                  T R                  S5        g)zW
Test that cancelling a deferred after it has been callbacked does
not cause an error.
c                ób   >• T=R                   S-  sl         U R                  [        5       5        g r‡  ©r  rÆ   rD   r)  s    €r:   r&  Ú?DeferredCancellerTests.test_cancelAfterCallback.<locals>.cancel^	  ó"   ø€ Ø×#Ò# qÑ(Õ#Ø�I‰I”l“nÕ%r=   rs  zbiff!r   Nr,  )r!   rÅ   r›   r£   rP   r&  r^   r  r«   r�   rŽ   r2  s   `  r:   Útest_cancelAfterCallbackÚ/DeferredCancellerTests.test_cancelAfterCallbackX	  s   ø€ ÷	&ô $¨fÑ5ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�
‰
�7ÔØ	�‰Œ
Ø×Ñ˜×0Ñ0°!Ô4Ø×Ñ˜$×-Ñ-Ô.Ø×Ñ˜×-Ñ-¨wÕ7r=   c                ó¦  ^ • SU 4S jjn[        US9nUR                  T R                  T R                  5        UR	                  [        5       5        UR                  5         T R                  T R                  S5        T R                  c   eT R                  T R                  R                  [
        5        T R                  T R                  5        g)zn
Test that cancelling a L{Deferred} after it has been errbacked does
not result in a L{defer.CancelledError}.
c                ób   >• T=R                   S-  sl         U R                  [        5       5        g r‡  r<  r)  s    €r:   r&  Ú>DeferredCancellerTests.test_cancelAfterErrback.<locals>.cancelp	  r>  r=   rs  r   Nr,  )r!   rÅ   r›   r£   rÆ   rD   r&  r^   r  r�   rþ   r«   rŽ   r2  s   `  r:   Útest_cancelAfterErrbackÚ.DeferredCancellerTests.test_cancelAfterErrbackj	  s™   ø€ ÷	&ô %¨vÑ6ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�	‰	”,“.Ô!Ø	�‰Œ
Ø×Ñ˜×0Ñ0°!Ô4Ø×"Ñ"Ñ.Ð.Ð.Ø×Ñ˜×,Ñ,×1Ñ1´<Ô@Ø×Ñ˜$×.Ñ.Õ/r=   c                ó>  ^ • SU 4S jjn[        US9nUR                  T R                  T R                  5        UR	                  5         T R                  T R                  S5        T R                  c   eT R                  T R                  R                  [        5        g)z/
Test a canceller which errbacks its deferred.
c                ób   >• T=R                   S-  sl         U R                  [        5       5        g r‡  r<  r)  s    €r:   r&  ÚADeferredCancellerTests.test_cancellerThatErrbacks.<locals>.cancel‚	  r>  r=   rs  rZ   Nr,  )
r!   rÅ   r›   r£   r&  r^   r  r�   rþ   rD   r2  s   `  r:   Útest_cancellerThatErrbacksÚ1DeferredCancellerTests.test_cancellerThatErrbacks}	  sw   ø€ ÷
	&ô %¨vÑ6ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�‰Œ
Ø×Ñ˜×0Ñ0°!Ô4Ø×"Ñ"Ñ.Ð.Ð.Ø×Ñ˜×,Ñ,×1Ñ1´<Õ@r=   c                ó:  ^ • SU 4S jjn[        US9nUR                  T R                  T R                  5        UR	                  5         T R                  T R                  S5        T R                  T R                  S5        T R                  T R                  5        g)z,
Test a canceller which calls its deferred.
c                óR   >• T=R                   S-  sl         U R                  S5        g )NrZ   úhello!)r  rP   r)  s    €r:   r&  ÚBDeferredCancellerTests.test_cancellerThatCallbacks.<locals>.cancel’	  s    ø€ Ø×#Ò# qÑ(Õ#Ø�J‰J�xÕ r=   rs  rZ   rM  Nr,  )
r!   rÅ   r›   r£   r&  r^   r  rŽ   r«   r�   r2  s   `  r:   Útest_cancellerThatCallbacksÚ2DeferredCancellerTests.test_cancellerThatCallbacks�	  ss   ø€ ÷
	!ô %¨vÑ6ˆØ	�‰�t—~‘~ t§}¡}Ô5Ø	�‰Œ
Ø×Ñ˜×0Ñ0°!Ô4Ø×Ñ˜×-Ñ-¨xÔ8Ø×Ñ˜$×-Ñ-Õ.r=   c                óÂ  ^ ^• SU 4S jjnSU 4S jjn[        US9m[        US9nUR                  S5        UR                  U4S j5        UR                  5         UR	                  T R
                  T R                  5        T R                  T R                  S5        T R                  c   eT R                  T R                  R                  [        R                  5        g)z¥
Verify that a Deferred, a, which is waiting on another Deferred, b,
returned from one of its callbacks, will propagate
L{defer.CancelledError} when a is cancelled.
c                ó0   >• T=R                   S-  sl         g r‡  r(  r)  s    €r:   ÚinnerCancelÚEDeferredCancellerTests.test_cancelNestedDeferred.<locals>.innerCancel¤	  r+  r=   c                ó(   >• TR                  S5        g ©NF)r`   r)  s    €r:   r&  Ú@DeferredCancellerTests.test_cancelNestedDeferred.<locals>.cancel§	  s   ø€ Ø�O‰O˜EÕ"r=   rs  Nc                ó   >• T$ r4   rF   )r  rÁ  s    €r:   r  ÚBDeferredCancellerTests.test_cancelNestedDeferred.<locals>.<lambda>­	  s   ø€ ¡1r=   rZ   r,  )r!   rP   rª   r&  rÅ   r›   r£   r^   r  r�   rþ   r   r   )rc   rS  r&  r;  rÁ  s   `   @r:   Útest_cancelNestedDeferredÚ0DeferredCancellerTests.test_cancelNestedDeferred�	  s¦   ù€ ÷	)÷	#ô %¨{Ñ;ˆÜ$¨vÑ6ˆØ	�
‰
�4ÔØ	�‰”nÔ%Ø	�‰Œ
Ø	�‰�t—~‘~ t§}¡}Ô5à×Ñ˜×0Ñ0°!Ô4ð ×"Ñ"Ñ.Ð.Ð.Ø×Ñ˜×,Ñ,×1Ñ1´5×3GÑ3GÕHr=   )r�   rŽ   r  r�   Nr‰   )r  rË   r?   rË   )r  rË   r?   r„   )rs   r0   r?   r„   )rH   rI   rJ   rK   r•   r°  r›   rŸ   r£   r  r  r  r  r!  r$  r-  r3  r8  r?  rD  rI  rO  rZ  rL   rF   r=   r:   r  r  ®  sf   † ô$ô7ôô%ô$ô
0ôLô"Lô";ô;ô$;ô5ô,Lô*
ô8ô$0ô&Aô /÷ Ir=   r  c                  ó†   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrSS jrSrg)ÚLogTestsi¸	  z#
Test logging of unhandled errors.
c                óf   • / U l         [        R                  " U R                   R                  5        g)z,
Add a custom observer to observer logging.
N)Úcr-   r…   r]   r”   s    r:   r•   ÚLogTests.setUp½	  s   € ð (*ˆŒÜ�Š˜Ÿ™Ÿ™Õ&r=   c                óX   • [         R                  " U R                  R                  5        g)z
Remove the observer.
N)r-   ÚremoveObserverr_  r]   r”   s    r:   r°  ÚLogTests.tearDownÄ	  s   € ô 	×Ò˜4Ÿ6™6Ÿ=™=Õ)r=   c                ó\   • U R                    Vs/ s H  oS   (       d  M  UPM     sn$ s  snf )NÚisError©r_  )rc   r  s     r:   Ú_loggedErrorsÚLogTests._loggedErrorsÊ	  s"   € ØŸ6š6Ó2š6�a y¥\—™6Ñ2Ð2ùÒ2s   �) )c                óº   • U R                  5       nU R                  [        U5      S5        US   S   R                  [        5        U R                  [        5        g)zF
Check the output of the log observer to see if the error is present.
rá   rZ   rá  N)rg  r^   r_   rà  rr  rq   )rc   Úc2s     r:   rå  ÚLogTests._checkÍ	  sM   € ð ×ÑÓ!ˆØ×Ñœ˜R› !Ô$Ø
ˆ1‰ˆiÑ×ÑÔ/Ô0Ø×ÑÔ0Õ1r=   c                ó    • [        5       R                  S 5      R                  S5        [        R                  " 5         U R                  5         g)zº
Verify that when a L{Deferred} with no references to it is fired,
and its final result (the one not handled by any callback) is an
exception, that exception will be logged immediately.
c                ó   • SS-  $ rm  rF   rÐ  s    r:   r  Ú(LogTests.test_errorLog.<locals>.<lambda>Ü	  ó   € ¨¨aªr=   rZ   N)r!   rª   rP   ÚgcÚcollectrå  r”   s    r:   Útest_errorLogÚLogTests.test_errorLogÖ	  s2   € ô 	‹
×ÑÑ/Ó0×9Ñ9¸!Ô<Ü
�
Š
ŒØ�‰�r=   c                óf   • SS jnU" 5         [         R                  " 5         U R                  5         g)z4
Same as L{test_errorLog}, but with an inner frame.
c                 ó^   • [        5       n U R                  S 5        U R                  S5        g )Nc                ó   • SS-  $ rm  rF   rÐ  s    r:   r  Ú`LogTests.test_errorLogWithInnerFrameRef.<locals>._subErrorLogWithInnerFrameRef.<locals>.<lambda>ç	  ó   €  A¨¢Fr=   rZ   )r!   rª   rP   r‹  s    r:   Ú_subErrorLogWithInnerFrameRefÚNLogTests.test_errorLogWithInnerFrameRef.<locals>._subErrorLogWithInnerFrameRefå	  s!   € Ü'›zˆAØ�M‰MÑ*Ô+Ø�J‰J�q�Mr=   Nr‰   ©rp  rq  rå  )rc   ry  s     r:   Útest_errorLogWithInnerFrameRefÚ'LogTests.test_errorLogWithInnerFrameRefà	  s!   € ô
	ñ
 	&Ô'Ü
�
Š
ŒØ�‰�r=   c                óf   • SS jnU" 5         [         R                  " 5         U R                  5         g)zA
Same as L{test_errorLogWithInnerFrameRef}, plus create a cycle.
c                 óx   • [        5       n U 4SS jjnU R                  U5        X l        U R                  S5        g )Nc                ó   • SS-  $ rm  rF   )rÑ  rZ  s     r:   ÚunusedCycleÚgLogTests.test_errorLogWithInnerFrameCycle.<locals>._subErrorLogWithInnerFrameCycle.<locals>.unusedCycleö	  s   € Ø˜A‘v�r=   rZ   )rÑ  rt  rZ  úDeferred[int]r?   rt  )r!   rª   Ú_drP   )rZ  r�  s     r:   Ú_subErrorLogWithInnerFrameCycleÚRLogTests.test_errorLogWithInnerFrameCycle.<locals>._subErrorLogWithInnerFrameCycleó	  s/   € Ü'›zˆAà78ö ð �M‰M˜+Ô&àŒDØ�J‰J�q�Mr=   Nr‰   r{  )rc   r…  s     r:   Ú test_errorLogWithInnerFrameCycleÚ)LogTests.test_errorLogWithInnerFrameCycleî	  s!   € ô
		ñ 	(Ô)Ü
�
Š
ŒØ�‰�r=   c                óˆ  • [        5       R                  S 5      R                  S5        [        R                  " 5         U R                  5         U R                  S[        U R                  5      5        [        R                  " U R                  S   5      nUc   eSnU R                  UR                  U5      SU< 35        g)z…
Verify that when a L{Deferred} with no references to it is fired,
the logged message does not contain a repr of the failure object.
c                ó   • SS-  $ rm  rF   rÐ  s    r:   r  Ú.LogTests.test_errorLogNoRepr.<locals>.<lambda>
  ro  r=   rZ   rá   ra  Nrƒ   ú Expected message starting with: )r!   rª   rP   rp  rq  rå  r^   r_   r_  r-   r}   r`   r†   )rc   Úmsgr¡  s      r:   Útest_errorLogNoReprÚLogTests.test_errorLogNoRepr
  s“   € ô
 	‹
×ÑÑ/Ó0×9Ñ9¸!Ô<ä
�
Š
ŒØ�‰Œà×Ñ˜œC §¡›KÔ(Ü×#Ò# D§F¡F¨2¡JÓ/ˆØ‰ÐˆØ0ˆØ�‰Ø�N‰N˜8Ó$Ø.¨x©lÐ;õ	
r=   c                óN  • SS jnU" 5         [         R                  " 5         U R                  5         U R                  S[	        U R
                  5      5        [        R                  " U R
                  S   5      nUc   eSnU R                  UR                  U5      SU< 35        g)z“
Verify that when a L{Deferred} with no references to it is fired,
the logged message includes debug info if debugging on the deferred
is enabled.
c                 ól   • [        5       n SU l        U R                  S 5        U R                  S5        g )NTc                ó   • SS-  $ rm  rF   rÐ  s    r:   r  Ú?LogTests.test_errorLogDebugInfo.<locals>.doit.<locals>.<lambda>
  rx  r=   rZ   )r!   Údebugrª   rP   r‹  s    r:   ÚdoitÚ-LogTests.test_errorLogDebugInfo.<locals>.doit
  s(   € Ü'›zˆAØˆAŒGØ�M‰MÑ*Ô+Ø�J‰J�q�Mr=   rá   ra  Nz
(debug:  IrŒ  r‰   )
rp  rq  rå  r^   r_   r_  r-   r}   r`   r†   )rc   r•  r�  r¡  s       r:   Útest_errorLogDebugInfoÚLogTests.test_errorLogDebugInfo
  s�   € ô	ñ 	ŒÜ
�
Š
ŒØ�‰Œà×Ñ˜œC §¡›KÔ(Ü×#Ò# D§F¡F¨2¡JÓ/ˆØ‰ÐˆØˆØ�‰Ø�N‰N˜8Ó$Ø.¨x©lÐ;õ	
r=   c                ó¬  • [        5       nUR                  S 5        UR                  S5        / n/ nUR                  UR                  UR                  5        U R                  U/ 5        U R                  [        U5      S5        US   R                  [        5        AAA[        R                  " 5         U R                  U R                  5       / 5        g)zŸ
If one Deferred with an error result is returned from a callback on
another Deferred, when the first Deferred is garbage collected it does
not log its error.
c                ó@   • [         R                  " [        S5      5      $ )NÚzoop)r   rc  ro   rü  s    r:   r  Ú3LogTests.test_chainedErrorCleanup.<locals>.<lambda>6
  s   € ¤%§*¢*¬\¸&Ó-AÔ"Br=   NrZ   r   )r!   rª   rP   rÅ   r]   r^   r_   rà  r  rp  rq  rg  )rc   rZ  r²  rx   s       r:   Útest_chainedErrorCleanupÚ!LogTests.test_chainedErrorCleanup/
  s§   € ô %›JˆØ	�‰ÑBÔCØ	�
‰
�4Ôð !ˆØ "ˆØ	�‰�w—~‘~ v§}¡}Ô5Ø×Ñ˜ "Ô%Ø×Ñœ˜V› aÔ(Øˆq‰	�‰”yÔ!ð �V˜Qô 	�
Š
Œà×Ñ˜×+Ñ+Ó-¨rÕ2r=   c                óþ   ^• [         R                  " [        S5      5      n[        5       mUc   eUR	                  U4S j5        S=mn[
        R                  " 5         U R                  U R                  5       / 5        g)zœ
If a Deferred with a failure result has an errback which chains it to
another Deferred, the initial failure is cleared by the errback so it is
not logged.
zoh noNc                ó   >• T$ r4   rF   )rž  Úgoods    €r:   r  Ú6LogTests.test_errorClearedByChaining.<locals>.<lambda>V
  s   ø€ ¡tr=   )	r   rc  r  r!   r\   rp  rq  r^   rg  )rc   Úbadr¡  s     @r:   Útest_errorClearedByChainingÚ$LogTests.test_errorClearedByChainingK
  sd   ø€ ô ).¯
ª
´9¸WÓ3EÓ(FˆÜ)1«ˆà‰ÐˆØ�‰Ô+Ô,ð ÐˆˆsÜ
�
Š
ŒØ×Ñ˜×+Ñ+Ó-¨rÕ2r=   rf  Nr‰   )r?   zList[Dict[str, Any]])rH   rI   rJ   rK   rj   r•   r°  rg  rå  rr  r|  r‡  rŽ  r—  r�  r¤  rL   rF   r=   r:   r]  r]  ¸	  s>   † ñô'ô*ô3ô2ôôôô(
ô&
ô43÷83r=   r]  c                  ó<   • \ rS rSrSS jrSS jrS	S jrSS jrSrg)
ÚDeferredListEmptyTestsi^
  c                ó   • SU l         g r˜   ©ÚcallbackRanr”   s    r:   r•   ÚDeferredListEmptyTests.setUp_
  s
   € ØˆÕr=   c                óP   • [        / 5      nUR                  U R                  5        g)zTesting empty DeferredList.N)r#   rª   Úcb_empty)rc   rê   s     r:   ÚtestDeferredListEmptyÚ,DeferredListEmptyTests.testDeferredListEmptyb
  s   € ä9EÀbÓ9IˆØ
�‰�t—}‘}Õ%r=   c                ó6   • SU l         U R                  / U5        g r‡  )rª  r^   )rc   Úress     r:   r­  ÚDeferredListEmptyTests.cb_emptyg
  s   € ØˆÔØ×Ñ˜˜SÕ!r=   c                ó<   • U R                  U R                  S5        g )NzCallback was never run.)r`   rª  r”   s    r:   r°  ÚDeferredListEmptyTests.tearDownk
  s   € Ø�‰˜×(Ñ(Ð*CÕDr=   r©  Nr‰   )r±  zList[Tuple[bool, object]]r?   r„   )	rH   rI   rJ   rK   r•   r®  r­  r°  rL   rF   r=   r:   r§  r§  ^
  s   † ôô&ô
"÷Er=   r§  c                  óŒ   • \ rS rSrSS jrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrSS jrSrg)ÚOtherPrimitivesTestsio
  c                ó.   • U =R                   S-  sl         g r‡  ©Úcounter©rc   rt   s     r:   Ú_incrÚOtherPrimitivesTests._incrp
  s   € Ø�Š˜ÑŽr=   c                ó   • SU l         g r˜   r¸  r”   s    r:   r•   ÚOtherPrimitivesTests.setUps
  s	   € Øˆ�r=   c                óV  ^
• [        5       nUR                  5       R                  U R                  5        U R	                  UR
                  5        U R                  U R                  S5        UR                  5       R                  U R                  5        U R	                  UR
                  5        U R                  U R                  S5        UR                  5         U R	                  UR
                  5        U R                  U R                  S5        UR                  5         U R                  UR
                  5        U R                  U R                  S5        U R                  [        UR                  5        [        5       n[        5       n[        5       nS m
SS	U
4S jjjnUR                  XRUS9nU R	                  UR
                  5        U R                  T
U5        UR                  U5        UR                  5       R                  U R                  5        U R	                  UR
                  5        U R                  U R                  S5        UR                  U5        U R                  T
U5        U R	                  UR
                  5        U R                  U R                  S5        UR                  5       R!                  U5      nUR#                  5         U R%                  T
[&        5        U R                  [)        [&        T
5      R*                  [,        R.                  5        UR                  5         U R                  UR
                  5        S
S jnSS jn	[1        UR                  U5      [        [2           5        [1        UR                  U	5      [        [2           5        g )NrZ   rá   c                ó   >• U mU$ r4   rF   )ÚresultValueÚreturnValuert   s     €r:   ÚhelperÚ-OtherPrimitivesTests.testLock.<locals>.helper‘
  s   ø€ à ˆFØÐr=   )rÁ  rÂ  rb  c                 ó.   • [         R                  " S5      $ ri  ©r   rW  rF   r=   r:   r8  Ú1OtherPrimitivesTests.testLock.<locals>.returnsInt¯
  s   € Ü—=’= Ó#Ð#r=   c               “  ó   #   • g7fr‡  rF   rF   r=   r:   ÚreturnsCoroIntÚ5OtherPrimitivesTests.testLock.<locals>.returnsCoroInt²
  r÷  rø  r4   )rÁ  r>   rÂ  r>   r?   r>   )r?   rƒ  rù  )r$   Úacquirerª   r»  r`   Úlockedr^   r¹  Úreleaser0  rC  rã  Úrunr>   r!   rP   r   r&  rs  r0   r   rþ   r   r   r   rt  )rc   ÚlockÚfirstUniqueÚsecondUniqueÚcontrolDeferredrÃ  ÚresultDeferredrZ  r8  rÉ  rt   s             @r:   ÚtestLockÚOtherPrimitivesTests.testLockv
  s…  ø€ Ü‹~ˆØ�‰‹×"Ñ" 4§:¡:Ô.Ø�‰˜Ÿ™Ô$Ø×Ñ˜Ÿ™ qÔ)à�‰‹×"Ñ" 4§:¡:Ô.Ø�‰˜Ÿ™Ô$Ø×Ñ˜Ÿ™ qÔ)à�‰ŒØ�‰˜Ÿ™Ô$Ø×Ñ˜Ÿ™ qÔ)à�‰ŒØ×Ñ˜Ÿ™Ô%Ø×Ñ˜Ÿ™ qÔ)à×Ñœ) T§X¡XÔ.ä“hˆÜ“xˆä,4«Jˆà#'ˆ÷	ñ 	ð
 Ÿ™Ø¸ð "ð 
ˆð 	�‰˜Ÿ™Ô$Ø×Ñ˜ Ô-à×"Ñ" 6Ô*à�‰‹×"Ñ" 4§:¡:Ô.Ø�‰˜Ÿ™Ô$Ø×Ñ˜Ÿ™ qÔ)à× Ñ  Ô.Ø×Ñ˜ Ô.Ø�‰˜Ÿ™Ô$Ø×Ñ˜Ÿ™ qÔ)à�L‰L‹N×"Ñ" 6Ó*ˆØ	�‰Œ
Ø×Ñ˜f¤gÔ.Ø×Ñœœg vÓ.×3Ñ3´U×5IÑ5IÔJà�‰ŒØ×Ñ˜Ÿ™Ô%ô	$ô	ô 	�D—H‘H˜ZÓ(¬(´3©-Ô8Ü�D—H‘H˜^Ó,¬h´s©mÕ<r=   c                óŒ   ^ • SU 4S jjn[        5       nUR                  5       nUR                  U5        UR                  5         g)zr
When canceling a L{Deferred} from a L{DeferredLock} that already
has the lock, the cancel should have no effect.
c                ó(   >• TR                  S5        g ©NzUnexpected errback call!©rc  ©r9   rc   s    €r:   ÚfailOnErrbackÚHOtherPrimitivesTests.test_cancelLockAfterAcquired.<locals>.failOnErrback¾
  ó   ø€ Ø�I‰IÐ0Õ1r=   N©r9   r0   r?   r„   )r$   rË  r\   r&  )rc   rÛ  rÏ  rZ  s   `   r:   Útest_cancelLockAfterAcquiredÚ1OtherPrimitivesTests.test_cancelLockAfterAcquired¸
  s1   ø€ ÷	2ô ‹~ˆØ�L‰L‹NˆØ	�‰�]Ô#Ø	�‰�
r=   c                ó¸   • [        5       nUR                  5         UR                  5       nUR                  5         U R                  U[        R
                  5        g)z·
When canceling a L{Deferred} from a L{DeferredLock} that does not
yet have the lock (i.e., the L{Deferred} has not fired), the cancel
should cause a L{defer.CancelledError} failure.
N)r$   rË  r&  rg   r   r   )rc   rÏ  rZ  s      r:   Útest_cancelLockBeforeAcquiredÚ2OtherPrimitivesTests.test_cancelLockBeforeAcquiredÆ
  s>   € ô ‹~ˆØ�‰ŒØ�L‰L‹NˆØ	�‰Œ
Ø×#Ñ# A¤u×';Ñ';Õ<r=   c                ó®  ^^^• Sn[        U5      n[        5       mS mS	UU4S jjn/ n[        5       nUR                  X5S9nUR	                  UR
                  5        UR	                  U R                  5        U R                  U/ 5        U R                  TU5        TR                  S 5        U R                  UR                  5       5        U R                  U R                  S5        SU l        [        SSU-   5       HH  nUR                  5       R	                  U R                  5        U R                  U R                  U5        MJ     / mS
U4S jjnS
U4S jjn	UR                  5       R                  X‰5      n
U
R                  5         U R                  TS/5        UR                  5       R	                  U R                  5        U R                  U R                  U5        UR!                  5         U R                  U R                  US-   5        [        SSU-   5       H2  nUR!                  5         U R                  U R                  US-   5        M4     g )NrŸ  c                ó   >• U mT$ r4   rF   )ÚargrÒ  Ú	helperArgs    €€r:   rÃ  Ú2OtherPrimitivesTests.testSemaphore.<locals>.helperÚ
  s   ø€ àˆIØ"Ð"r=   )ræ  rZ   r   c                ó(   >• TR                  S5        g rV  rï   ©r}  rV  s    €r:   rc  Ú0OtherPrimitivesTests.testSemaphore.<locals>.failñ
  s   ø€ Ø�N‰N˜5Õ!r=   c                ó(   >• TR                  S5        g r¬  rï   rê  s    €r:   rW  Ú3OtherPrimitivesTests.testSemaphore.<locals>.succeedô
  s   ø€ Ø�N‰N˜4Õ r=   T)ræ  r>   r?   rO  )r}  r>   r?   r„   )r&   r!   r>   rÎ  rª   r]   r»  r^   rP   r«   r  r¹  r  rË  rÅ   r&  rÍ  )rc   ÚNÚsemrÃ  r²  ÚuniqueObjectrÓ  Úirc  rW  rZ  rÒ  rç  rV  s              @@@r:   ÚtestSemaphoreÚ"OtherPrimitivesTests.testSemaphoreÒ
  sÍ  ú€ ØˆÜ Ó"ˆä*2«*ˆà ˆ	÷	#ð 	#ð
 !#ˆÜ“xˆØŸ™ ˜Ð:ˆØ×"Ñ" 7§>¡>Ô2Ø×"Ñ" 4§:¡:Ô.Ø×Ñ˜ "Ô%Ø×Ñ˜ LÔ1Ø× Ñ  Ô&Ø×Ñ˜'Ÿ+™+›-Ô(Ø×Ñ˜Ÿ™ qÔ)àˆŒÜ�q˜!˜a™%–ˆAØ�K‰K‹M×%Ñ% d§j¡jÔ1Ø×Ñ˜TŸ\™\¨1Ö-ñ !ð ˆ÷	"÷	!ð �K‰K‹M×&Ñ& tÓ5ˆØ	�‰Œ
Ø×Ñ˜ 4 &Ô)à�‰‹×!Ñ! $§*¡*Ô-Ø×Ñ˜Ÿ™ qÔ)à�‰ŒØ×Ñ˜Ÿ™ q¨1¡uÔ-ä�q˜!˜a™%–ˆAØ�K‰KŒMØ×Ñ˜TŸ\™\¨1¨q©5Ö1ò !r=   c                óp   • U R                  [        [        S5        U R                  [        [        S5        g)zb
If the token count passed to L{DeferredSemaphore} is less than one
then L{ValueError} is raised.
r   ra  N)rC  r™  r&   r”   s    r:   Útest_semaphoreInvalidTokensÚ0OtherPrimitivesTests.test_semaphoreInvalidTokens  s*   € ð
 	×Ñœ*Ô&7¸Ô;Ø×Ñœ*Ô&7¸Õ<r=   c                óŽ   ^ • SU 4S jjn[        S5      nUR                  5       nUR                  U5        UR                  5         g)z|
When canceling a L{Deferred} from a L{DeferredSemaphore} that
already has the semaphore, the cancel should have no effect.
c                ó(   >• TR                  S5        g rØ  rÙ  rÚ  s    €r:   rÛ  ÚMOtherPrimitivesTests.test_cancelSemaphoreAfterAcquired.<locals>.failOnErrback  rÝ  r=   rZ   NrÞ  )r&   rË  r\   r&  )rc   rÛ  rï  rZ  s   `   r:   Ú!test_cancelSemaphoreAfterAcquiredÚ6OtherPrimitivesTests.test_cancelSemaphoreAfterAcquired  s4   ø€ ÷	2ô   Ó"ˆØ�K‰K‹MˆØ	�‰�]Ô#Ø	�‰�
r=   c                óº   • [        S5      nUR                  5         UR                  5       nUR                  5         U R                  U[        R
                  5        g)zÁ
When canceling a L{Deferred} from a L{DeferredSemaphore} that does
not yet have the semaphore (i.e., the L{Deferred} has not fired),
the cancel should cause a L{defer.CancelledError} failure.
rZ   N)r&   rË  r&  rg   r   r   )rc   rï  rZ  s      r:   Ú"test_cancelSemaphoreBeforeAcquiredÚ7OtherPrimitivesTests.test_cancelSemaphoreBeforeAcquired  sA   € ô   Ó"ˆØ�‰ŒØ�K‰K‹MˆØ	�‰Œ
Ø×#Ñ# A¤u×';Ñ';Õ<r=   c                ó$  • Su  p[        X5      n/ n[        U5       H,  nUR                  5       R                  UR                  5        M.     U R                  [        R                  UR                  5        [        U5       H;  nUR                  U5        U R                  U[        [        US-   5      5      5        M=     [        U5       H:  nUR                  X-   5        U R                  U[        [        U5      5      5        M<     U R                  [        R                  UR                  S 5        / n[        U5       HV  nUR                  5       R                  UR                  5        U R                  U[        [        XU-   S-   5      5      5        MX     [        5       n/ n[        U5       H,  nUR                  5       R                  UR                  5        M.     [        U5       H  nUR                  U5        M     U R                  U[        [        U5      5      5        [        SS9nU R                  [        R                  UR                  S 5        [        SS9nU R                  [        R                  UR                  5        g )N)rá   rá   rZ   r   )Úsize)Úbacklog)r%   r  Úgetrª   r]   rC  r   ÚQueueUnderflowÚputr^   ÚlistÚQueueOverflow)rc   rî  ÚMÚqueueÚgottenrñ  s         r:   Ú	testQueueÚOtherPrimitivesTests.testQueue'  sÞ  € Ø‰ˆÜ$1°!Ó$7ˆàˆä�q–ˆAØ�I‰I‹K×#Ñ# F§M¡MÖ2ñ à×Ñœ%×.Ñ.°·	±	Ô:ä�q–ˆAØ�I‰I�aŒLØ×Ñ˜V¤T¬%°°A±«,Ó%7Ö8ñ ô �q–ˆAØ�I‰I�a‘eÔØ×Ñ˜V¤T¬%°«(£^Ö4ñ ð 	×Ñœ%×-Ñ-¨u¯y©y¸$Ô?àˆÜ�q–ˆAØ�I‰I‹K×#Ñ# F§M¡MÔ2Ø×Ñ˜V¤T¬%°°q±5¸1±9Ó*=Ó%>Ö?ñ ô “ˆØˆÜ�q–ˆAØ�I‰I‹K×#Ñ# F§M¡MÖ2ñ ä�q–ˆAØ�I‰I�aŽLñ à×Ñ˜¤¤e¨A£h£Ô0ä 1Ñ%ˆØ×Ñœ%×-Ñ-¨u¯y©y¸$Ô?ä aÑ(ˆØ×Ñœ%×.Ñ.°·	±	Õ:r=   c                ó®   ^ • SU 4S jjn[        5       nUR                  5       nUR                  U5        UR                  S5        UR	                  5         g)zs
When canceling a L{Deferred} from a L{DeferredQueue} that already has
a result, the cancel should have no effect.
c                ó(   >• TR                  S5        g rØ  rÙ  rÚ  s    €r:   rÛ  ÚOOtherPrimitivesTests.test_cancelQueueAfterSynchronousGet.<locals>.failOnErrbackR  rÝ  r=   NrÞ  )r%   r  r\   r  r&  )rc   rÛ  r  rZ  s   `   r:   Ú#test_cancelQueueAfterSynchronousGetÚ8OtherPrimitivesTests.test_cancelQueueAfterSynchronousGetL  s<   ø€ ÷	2ô &3£_ˆØ�I‰I‹KˆØ	�‰�]Ô#Ø�	‰	�$ŒØ	�‰�
r=   c                ó@  ^ ^• [        5       mTR                  5       nUR                  5         T R                  U[        R
                  5        SUU 4S jjnUR                  U5        / nUR                  UR                  5        T R                  [        U5      S5        g)z÷
When canceling a L{Deferred} from a L{DeferredQueue} that does not
have a result (i.e., the L{Deferred} has not fired), the cancel
causes a L{defer.CancelledError} failure. If the queue has a result
later on, it doesn't try to fire the deferred.
c                óz   >• TR                  S 5        TR                  5       R                  TR                  S 5      $ r4   )r  r  rª   rr   )Úignorer  rc   s    €€r:   rÖ   Ú9OtherPrimitivesTests.test_cancelQueueAfterGet.<locals>.cbg  s-   ø€ ð �I‰I�dŒOØ—9‘9“;×*Ñ*¨4¯=©=¸$Ó?Ð?r=   rZ   N)r  r>   r?   rO  )
r%   r  r&  rg   r   r   rª   r]   r^   r_   )rc   rZ  rÖ   Údoner  s   `   @r:   Útest_cancelQueueAfterGetÚ-OtherPrimitivesTests.test_cancelQueueAfterGet[  sy   ù€ ô &3£_ˆØ�I‰I‹KˆØ	�‰Œ
Ø×#Ñ# A¤u×';Ñ';Ô<÷	@ð 	@ð 	
�‰�bÔØˆØ	�‰�d—k‘kÔ"Ø×Ñœ˜T› AÕ&r=   r¸  Nr�  r‰   )rH   rI   rJ   rK   r»  r•   rÔ  rß  râ  rò  rõ  rú  rý  r
  r  r  rL   rF   r=   r:   r¶  r¶  o
  sB   † ôôô@=ôDô
=ô12ôf=ôô
=ô#;ôJ÷'r=   r¶  c                  ór   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSrg)ÚDeferredFilesystemLockTestsis  z0
Test the behavior of L{DeferredFilesystemLock}
c                óp   • [        5       U l        [        U R                  5       U R                  S9U l        g )N)Ú	scheduler)r,   Úclockr"   ÚmktemprÏ  r”   s    r:   r•   Ú!DeferredFilesystemLockTests.setUpx  s#   € Ü“WˆŒ
Ü*¨4¯;©;«=ÀDÇJÁJÑOˆ�	r=   c                ó4   • U R                   R                  SS9$ )z9
Test that the lock can be acquired when no lock is held
rZ   ©Útimeout)rÏ  ÚdeferUntilLockedr”   s    r:   Útest_waitUntilLockedWithNoLockÚ:DeferredFilesystemLockTests.test_waitUntilLockedWithNoLock|  s   € ð �y‰y×)Ñ)°!Ð)Ð4Ð4r=   c                ó  • U R                  U R                  R                  5       5        U R                  R                  SS9nU R                  U[        R
                  5        U R                  R                  S/S-  5        U$ )z[
Test that the lock can not be acquired when the lock is held
for longer than the timeout.
g      @r   rZ   rÔ  )r`   rÏ  r"  ÚassertFailurer   ÚTimeoutErrorr  Úpumprx  s     r:   Ú%test_waitUntilLockedWithTimeoutLockedÚADeferredFilesystemLockTests.test_waitUntilLockedWithTimeoutLocked‚  sc   € ð
 	�‰˜Ÿ	™	Ÿ™Ó(Ô)à�I‰I×&Ñ&¨sÐ&Ð3ˆØ×Ñ˜1œe×0Ñ0Ô1à�
‰
�‰˜˜˜b™Ô!àˆr=   c                ó\  ^ • SU 4S jjnT R                  T R                  R                  5       5        T R                  R                  ST R                  R                  5        T R                  R                  SS9nUR                  U5        T R                  R                  S/S-  5        U$ )zd
Test that a lock can be acquired while a lock is held
but the lock is unlocked before our timeout.
c                óf   >• U R                  [        R                  5        TR                  S5        g )NzShould not have timed out)rà  r   r'  rc  rÚ  s    €r:   Ú	onTimeoutÚVDeferredFilesystemLockTests.test_waitUntilLockedWithTimeoutUnlocked.<locals>.onTimeout–  s"   ø€ Ø�F‰F”5×%Ñ%Ô&Ø�I‰IÐ1Õ2r=   rZ   rÔ  r   rÞ  )r`   rÏ  r  Ú	callLaterÚunlockr"  r\   r(  )rc   r-  rZ  s   `  r:   Ú'test_waitUntilLockedWithTimeoutUnlockedÚCDeferredFilesystemLockTests.test_waitUntilLockedWithTimeoutUnlocked�  s}   ø€ ÷	3ð 	�‰˜Ÿ	™	Ÿ™Ó(Ô)à�
‰
×Ñ˜Q §	¡	× 0Ñ 0Ô1Ø�I‰I×&Ñ&¨rÐ&Ð2ˆØ	�‰�YÔà�
‰
�‰˜˜˜b™Ô!àˆr=   c                óv   • [        U R                  5       5      nU R                  UR                  [        5        g)z5
Test that the default scheduler is set up properly.
N)r"   r  r^   Ú
_schedulerr   ©rc   rÏ  s     r:   Útest_defaultSchedulerÚ1DeferredFilesystemLockTests.test_defaultScheduler¤  s(   € ô & d§k¡k£mÓ4ˆà×Ñ˜Ÿ™¬'Õ2r=   c                óx  • U R                   R                  5         U R                  R                  SU R                   R                  5        U R                   R	                  5       nU R                   R	                  5       nU R                  U[        R                  5        U R                  R                  S5        U$ )zd
Test that an appropriate exception is raised when attempting
to use deferUntilLocked concurrently.
rZ   )	rÏ  r  r/  r0  r"  r&  r   ÚAlreadyTryingToLockErrorÚadvancer‚  s      r:   Útest_concurrentUsageÚ0DeferredFilesystemLockTests.test_concurrentUsage¬  s�   € ð
 	�	‰	�‰ÔØ�
‰
×Ñ˜Q §	¡	× 0Ñ 0Ô1à�Y‰Y×'Ñ'Ó)ˆØ�Y‰Y×'Ñ'Ó)ˆà×Ñ˜2œu×=Ñ=Ô>à�
‰
×Ñ˜1Ôàˆ	r=   c                ó8  ^ • SU 4S jjnT R                   R                  5         T R                  R                  ST R                   R                  5        T R                   R	                  5       nUR                  U5        T R                  R                  S5        U$ )z?
Test that a DeferredFilesystemLock can be used multiple times
c                óp   >• TR                   R                  5         TR                   R                  5       nU$ r4   )rÏ  r0  r"  )r‡  rZ  rc   s     €r:   ÚlockAquiredÚDDeferredFilesystemLockTests.test_multipleUsages.<locals>.lockAquiredÂ  s*   ø€ Ø�I‰I×ÑÔØ—	‘	×*Ñ*Ó,ˆAØˆHr=   rZ   )r‡  r>   r?   rO  )rÏ  r  r/  r0  r"  rª   r:  )rc   r?  rZ  s   `  r:   Útest_multipleUsagesÚ/DeferredFilesystemLockTests.test_multipleUsages½  sk   ø€ ÷
	ð
 	�	‰	�‰ÔØ�
‰
×Ñ˜Q §	¡	× 0Ñ 0Ô1à�I‰I×&Ñ&Ó(ˆØ	�‰�kÔ"à�
‰
×Ñ˜1Ôàˆr=   c                óŠ  • U R                   R                  5         U R                   R                  5       nU R                   R                  nUc   eUR                  5         U R	                  UR                  5       5        U R                  U R                   R                  5        U R                  U[        R                  5        g)z�
When cancelling a L{Deferred} returned by
L{DeferredFilesystemLock.deferUntilLocked}, the
L{DeferredFilesystemLock._tryLockCall} is cancelled.
N)
rÏ  r"  Ú_tryLockCallr&  r0  Úactiver«   r'  r   r   )rc   rR   ÚtryLockCalls      r:   Útest_cancelDeferUntilLockedÚ7DeferredFilesystemLockTests.test_cancelDeferUntilLockedÑ  sŽ   € ð 	�	‰	�‰ÔØ—9‘9×-Ñ-Ó/ˆØ—i‘i×,Ñ,ˆØÑ&Ð&Ð&Ø�‰ÔØ×Ñ˜×+Ñ+Ó-Ô.Ø×Ñ˜$Ÿ)™)×0Ñ0Ô1Ø×Ñ˜X¤u×';Ñ';Õ<r=   c                óˆ  • U R                   R                  5         U R                   R                  SS9nU R                   R                  nUc   eUR                  5         U R	                  UR                  5       5        U R                  U R                   R                  5        U R                  U[        R                  5        g)zŽ
When cancel a L{Deferred} returned by
L{DeferredFilesystemLock.deferUntilLocked}, if the timeout is
set, the timeout call will be cancelled.
rZ   r   N)
rÏ  r"  Ú_timeoutCallr&  r0  rE  r«   r'  r   r   )rc   rR   ÚtimeoutCalls      r:   Ú&test_cancelDeferUntilLockedWithTimeoutÚBDeferredFilesystemLockTests.test_cancelDeferUntilLockedWithTimeoutà  s“   € ð 	�	‰	�‰ÔØ—9‘9×-Ñ-°aÐ-Ð8ˆØ—i‘i×,Ñ,ˆØÑ&Ð&Ð&Ø�‰ÔØ×Ñ˜×+Ñ+Ó-Ô.Ø×Ñ˜$Ÿ)™)×0Ñ0Ô1Ø×Ñ˜X¤u×';Ñ';Õ<r=   )r  rÏ  Nr‰   )r?   rO  )rH   rI   rJ   rK   rj   r•   r#  r)  r1  r6  r;  rA  rG  rL  rL   rF   r=   r:   r  r  s  s5   † ñôPô5ôôô(3ôô"ô(=÷=r=   r  c                ó   • g)z^
Private function to be used to pass as an alternate onTimeoutCancel value
to timeoutDeferred
Ú
OVERRIDDENrF   )ÚvÚts     r:   Ú_overrideFuncrR  ð  s   € ð
 r=   c                  óÌ   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)ÚDeferredAddTimeoutTestsiø  z/
Tests for the function L{Deferred.addTimeout}
c                óÔ   • [        5       nUR                  S[        5       5        UR                  S 5        UR	                  S5        U R                  SU R                  U5      5        g)z]
L{Deferred.addTimeout} returns its own L{Deferred} so it
can be called in a callback chain.
rÏ  c                ó   • g)Nr  rF   rn  s    r:   r  Ú?DeferredAddTimeoutTests.test_timeoutChainable.<locals>.<lambda>  s   €  r=   Nr  )r!   Ú
addTimeoutr,   rª   rP   r^   r/  rx  s     r:   Útest_timeoutChainableÚ-DeferredAddTimeoutTests.test_timeoutChainableý  sO   € ô
 %›JˆØ	�‰�Qœ›Ô Ø	�‰Ñ&Ô'Ø	�
‰
�4ÔØ×Ñ˜ ×!5Ñ!5°aÓ!8Õ9r=   c                óN  ^^• [        5       n[        5       nUR                  SU5        [        5       mSmSUU4S jjnUR                  U5        UR	                  S5        U R                  ST5        U R                  TS5        UR                  S5        U R                  T5        g)zª
The L{Deferred} callbacks with the result if it succeeds before
the timeout. No cancellation happens after the callback either,
which could also cancel inner deferreds.
rÔ  Nr²  c                ó   >• U mT$ r4   rF   ©r²  ÚdCallbackedÚinnerDeferreds    €€r:   Ú
onCallbackÚKDeferredAddTimeoutTests.test_successResultBeforeTimeout.<locals>.onCallback  ó   ø€ à!ˆKØ Ð r=   rÕ  ©r²  rË   r?   rO  )	r,   r!   rX  rª   rP   ÚassertIsNotr^   r:  rB  ©rc   r  rZ  r`  r^  r_  s       @@r:   Útest_successResultBeforeTimeoutÚ7DeferredAddTimeoutTests.test_successResultBeforeTimeout  s‘   ù€ ô “ˆÜ#›:ˆØ	�‰�R˜Ôô )1«
ˆØ%)ˆ÷	!ð 	!ð
 	
�‰�jÔ!Ø	�
‰
�9Ôð 	×Ñ˜˜{Ô+Ø×Ñ˜ iÔ0ð 	�‰�bÔØ×Ñ˜MÕ*r=   c                óT  ^^• [        5       n[        5       nUR                  SU[        S9  [        5       mSmSUU4S jjnUR	                  U5        UR                  S5        U R                  ST5        U R                  TS5        UR                  S5        U R                  T5        g)zä
The L{Deferred} callbacks with the result if it succeeds before
the timeout, even if a custom C{onTimeoutCancel} function is provided.
No cancellation happens after the callback either, which could also
cancel inner deferreds.
rÔ  ©ÚonTimeoutCancelNr²  c                ó   >• U mT$ r4   rF   r]  s    €€r:   r`  ÚQDeferredAddTimeoutTests.test_successResultBeforeTimeoutCustom.<locals>.onCallback9  rb  r=   rÕ  rc  )
r,   r!   rX  rR  rª   rP   rd  r^   r:  rB  re  s       @@r:   Ú%test_successResultBeforeTimeoutCustomÚ=DeferredAddTimeoutTests.test_successResultBeforeTimeoutCustom)  s•   ù€ ô “ˆÜ#›:ˆØ	�‰�R˜´ˆÑ>ô )1«
ˆØ%)ˆ÷	!ð 	!ð
 	
�‰�jÔ!Ø	�
‰
�9Ôð 	×Ñ˜˜{Ô+Ø×Ñ˜ iÔ0ð 	�‰�bÔØ×Ñ˜MÕ*r=   c                óŠ  ^^• [        5       n[        5       nUR                  SU5        [        5       mSm[        S5      nSUU4S jjnUR	                  U5        UR                  U5        Tc   eU R                  T[        5        U R                  TR                  U5        UR                  S5        U R                  T5        g)z¦
The L{Deferred} errbacks with the failure if it fails before the
timeout. No cancellation happens after the errback either, which
could also cancel inner deferreds.
rÔ  Nrc  c                ó   >• U mT$ r4   rF   ©r9   Ú
dErrbackedr_  s    €€r:   Ú	onErrbackÚDDeferredAddTimeoutTests.test_failureBeforeTimeout.<locals>.onErrback[  ó   ø€ àˆJØ Ð r=   rÕ  ©r9   r0   r?   rO  )r,   r!   rX  r™  r\   rÆ   rs  r0   rr   rb   r:  rB  ©rc   r  rZ  rs   rs  rr  r_  s        @@r:   Útest_failureBeforeTimeoutÚ1DeferredAddTimeoutTests.test_failureBeforeTimeoutK  s«   ù€ ô “ˆÜ$›JˆØ	�‰�R˜Ôô )1«
ˆØ(,ˆ
Ü˜6Ó"ˆ÷	!ð 	!ð
 	
�‰�YÔØ	�	‰	�%Ôð Ñ%Ð%Ð%Ø×Ñ˜j¬'Ô2Ø�‰�j×&Ñ&¨Ô.ð 	�‰�bÔØ×Ñ˜MÕ*r=   c                ó�  ^^• [        5       n[        5       nUR                  SU[        S9  [        5       mSm[	        S5      nSUU4S jjnUR                  U5        UR                  U5        Tc   eU R                  T[        5        U R                  TR                  U5        UR                  S5        U R                  T5        g)zÚ
The L{Deferred} errbacks with the failure if it fails before the
timeout, even if using a custom C{onTimeoutCancel} function.
No cancellation happens after the errback either, which could also
cancel inner deferreds.
rÔ  ri  Nrc  c                ó   >• U mT$ r4   rF   rq  s    €€r:   rs  ÚJDeferredAddTimeoutTests.test_failureBeforeTimeoutCustom.<locals>.onErrback  ru  r=   rÕ  rv  )r,   r!   rX  rR  r™  r\   rÆ   rs  r0   rr   rb   r:  rB  rw  s        @@r:   Útest_failureBeforeTimeoutCustomÚ7DeferredAddTimeoutTests.test_failureBeforeTimeoutCustomn  s¯   ù€ ô “ˆÜ$›JˆØ	�‰�R˜´ˆÑ>ô )1«
ˆØ(,ˆ
Ü˜6Ó"ˆ÷	!ð 	!ð
 	
�‰�YÔØ	�	‰	�%Ôð Ñ%Ð%Ð%Ø×Ñ˜j¬'Ô2Ø�‰�j×&Ñ&¨Ô.ð 	�‰�bÔØ×Ñ˜MÕ*r=   c                óÔ   • [        5       n[        5       nUR                  SU5        U R                  U5        UR	                  S5        U R                  U[        R                  5        g)zt
The L{Deferred} by default errbacks with a L{defer.TimeoutError}
if it times out before callbacking or errbacking.
rÔ  rÕ  N)r,   r!   rX  rB  r:  r'  r   r'  ©rc   r  rZ  s      r:   Útest_timedOutÚ%DeferredAddTimeoutTests.test_timedOut’  sP   € ô
 “ˆÜ$›JˆØ	�‰�R˜ÔØ×Ñ˜AÔà�‰�bÔà×Ñ˜Q¤× 2Ñ 2Õ3r=   c                óÜ   • [        5       n[        5       nUR                  SU[        S9  U R	                  U5        UR                  S5        U R                  SU R                  U5      5        g)a  
If a custom C{onTimeoutCancel] function is provided, the
L{Deferred} returns the custom function's return value if the
L{Deferred} times out before callbacking or errbacking.
The custom C{onTimeoutCancel} function can return a result instead of
a failure.
rÔ  ri  rÕ  rO  N©r,   r!   rX  rR  rB  r:  r^   r/  r€  s      r:   Útest_timedOutCustomÚ+DeferredAddTimeoutTests.test_timedOutCustom   sY   € ô “ˆÜ$›JˆØ	�‰�R˜´ˆÑ>Ø×Ñ˜AÔà�‰�bÔà×Ñ˜ t×';Ñ';¸AÓ'>Õ?r=   c                óÚ   • [        5       n[        S 5      nUR                  SU5        U R                  U5        UR	                  S5        U R                  U R                  U5      S5        g)z·
If a cancellation function is provided when the L{Deferred} is
initialized, the L{Deferred} returns the cancellation value's
non-failure return value when the L{Deferred} times out.
c                ó$   • U R                  S5      $ )NúI was cancelled!rO   rf  s    r:   r  ÚLDeferredAddTimeoutTests.test_timedOutProvidedCancelSuccess.<locals>.<lambda>¸  s   € ¨a¯j©jÐ9KÔ.Lr=   rÔ  rÕ  r‰  N)r,   r!   rX  rB  r:  r^   r/  r€  s      r:   Ú"test_timedOutProvidedCancelSuccessÚ:DeferredAddTimeoutTests.test_timedOutProvidedCancelSuccess±  sZ   € ô “ˆÜ#Ñ$LÓMˆØ	�‰�R˜ÔØ×Ñ˜AÔà�‰�bÔà×Ñ˜×-Ñ-¨aÓ0Ð2DÕEr=   c                ó  ^• [        5       n[        S5      m[        U4S j5      nUR                  SU5        U R	                  U5        UR                  S5        U R                  U[        5      nU R                  UR                  T5        g)z»
If a cancellation function is provided when the L{Deferred} is
initialized, the L{Deferred} returns the cancellation value's
non-L{CanceledError} failure when the L{Deferred} times out.
úwhat!c                ó&   >• U R                  T5      $ r4   )rÆ   )r_  rs   s    €r:   r  ÚLDeferredAddTimeoutTests.test_timedOutProvidedCancelFailure.<locals>.<lambda>È  s   ø€ ¨q¯y©y¸Ô/?r=   rÔ  rÕ  N)	r,   r™  r!   rX  rB  r:  r'  rr   rb   )rc   r  rZ  r9   rs   s       @r:   Ú"test_timedOutProvidedCancelFailureÚ:DeferredAddTimeoutTests.test_timedOutProvidedCancelFailureÀ  sm   ø€ ô “ˆÜ˜7Ó#ˆÜ$Ô%?Ó@ˆØ	�‰�R˜ÔØ×Ñ˜AÔà�‰�bÔà× Ñ  ¤JÓ/ˆØ�‰�a—g‘g˜uÕ%r=   c                óŽ  ^^• [        5       n[        5       nUR                  SU5        [        5       mSmSUU4S jjnUR                  U5        UR	                  5         Tc   eU R                  T[        5        U R                  TR                  [        R                  5        UR                  S5        U R                  T5        g)a  
If the L{Deferred} is manually cancelled before the timeout, it
is not re-cancelled (no L{AlreadyCancelled} error, and also no
canceling of inner deferreds), and the default C{onTimeoutCancel}
function is not called, preserving the original L{CancelledError}.
rÔ  Nc                ó   >• U mT$ r4   rF   ©r9   Ú	dCanceledr_  s    €€r:   rs  ÚCDeferredAddTimeoutTests.test_cancelBeforeTimeout.<locals>.onErrbacká  ó   ø€ àˆIØ Ð r=   rÕ  rv  )r,   r!   rX  r\   r&  rs  r0   rr   rþ   r   r   r:  rB  ©rc   r  rZ  rs  r–  r_  s       @@r:   Útest_cancelBeforeTimeoutÚ0DeferredAddTimeoutTests.test_cancelBeforeTimeoutÑ  s¢   ù€ ô “ˆÜ$›JˆØ	�‰�R˜Ôô )1«
ˆØˆ	÷	!ð 	!ð
 	
�‰�YÔØ	�‰Œ
ð Ñ$Ð$Ð$Ø×Ñ˜i¬Ô1Ø�‰�i—n‘n¤e×&:Ñ&:Ô;ð 	�‰�bÔØ×Ñ˜MÕ*r=   c                ó”  ^^• [        5       n[        5       nUR                  SU[        S9  [        5       mSmSUU4S jjnUR	                  U5        UR                  5         Tc   eU R                  T[        5        U R                  TR                  [        R                  5        UR                  S5        U R                  T5        g)a  
If the L{Deferred} is manually cancelled before the timeout, it
is not re-cancelled (no L{AlreadyCancelled} error, and also no
canceling of inner deferreds), and the custom C{onTimeoutCancel}
function is not called, preserving the original L{CancelledError}.
rÔ  ri  Nc                ó   >• U mT$ r4   rF   r•  s    €€r:   rs  ÚIDeferredAddTimeoutTests.test_cancelBeforeTimeoutCustom.<locals>.onErrback  r˜  r=   rÕ  rv  )r,   r!   rX  rR  r\   r&  rs  r0   rr   rþ   r   r   r:  rB  r™  s       @@r:   Útest_cancelBeforeTimeoutCustomÚ6DeferredAddTimeoutTests.test_cancelBeforeTimeoutCustomô  s¦   ù€ ô “ˆÜ$›JˆØ	�‰�R˜´ˆÑ>ô )1«
ˆØˆ	÷	!ð 	!ð
 	
�‰�YÔØ	�‰Œ
ð Ñ$Ð$Ð$Ø×Ñ˜i¬Ô1Ø�‰�i—n‘n¤e×&:Ñ&:Ô;ð 	�‰�bÔØ×Ñ˜MÕ*r=   c                óà   • [        5       n[        S 5      nUR                  SU[        S9  U R	                  U5        UR                  S5        U R                  SU R                  U5      5        g)z]
A custom translation function can handle a L{Deferred} with a
custom cancellation function.
c                ó6   • U R                  [        S5      5      $ )NrŽ  )rÆ   r™  rf  s    r:   r  ÚVDeferredAddTimeoutTests.test_providedCancelCalledBeforeTimeoutCustom.<locals>.<lambda>  s   € ¨q¯y©y¼ÀGÓ9LÔ/Mr=   rÔ  ri  rÕ  rO  Nr„  r€  s      r:   Ú,test_providedCancelCalledBeforeTimeoutCustomÚDDeferredAddTimeoutTests.test_providedCancelCalledBeforeTimeoutCustom  s]   € ô
 “ˆÜ$Ñ%MÓNˆØ	�‰�R˜´ˆÑ>Ø×Ñ˜AÔà�‰�bÔà×Ñ˜ t×';Ñ';¸AÓ'>Õ?r=   c                ót  ^• [        5       n[        5       nSmSU4S jjnUR                  U5        UR                  SU5        UR	                  S5        Tc   eU R                  T[        5        U R                  TR                  [        R                  5        U R                  U[        R                  5        g)zì
An errback added before a timeout is added errbacks with a
L{defer.CancelledError} when the timeout fires.  If the
errback returns the L{defer.CancelledError}, it is translated
to a L{defer.TimeoutError} by the timeout implementation.
Nc                ó   >• U mU $ r4   rF   ©r9   rr  s    €r:   rÆ   ÚGDeferredAddTimeoutTests.test_errbackAddedBeforeTimeout.<locals>.errback1  ó   ø€ àˆJØˆHr=   rÔ  rÕ  ©r9   r0   r?   r0   )r,   r!   r\   rX  r:  rs  r0   rb   r   r   r'  r'  ©rc   r  rZ  rÆ   rr  s       @r:   Útest_errbackAddedBeforeTimeoutÚ6DeferredAddTimeoutTests.test_errbackAddedBeforeTimeout%  s“   ø€ ô “ˆÜ$›Jˆàˆ
÷	ð
 	
�‰�WÔØ	�‰�R˜Ôà�‰�bÔàÑ%Ð%Ð%Ø×Ñ˜j¬'Ô2Ø×Ñ˜j×.Ñ.´×0DÑ0DÔEà×Ñ˜Q¤× 2Ñ 2Õ3r=   c                óV  ^• [        5       n[        5       nSmSU4S jjnUR                  U5        UR                  SU5        UR	                  S5        Tc   eU R                  T[        5        U R                  TR                  [        R                  5        U R                  U5        g)zÉ
An errback added before a timeout is added errbacks with a
L{defer.CancelledError} when the timeout fires.  If the
errback suppresses the L{defer.CancelledError}, the deferred
successfully completes.
Nc                óH   >• U mU R                  [        R                  5        g r4   )rà  r   r   r¨  s    €r:   rÆ   Ú]DeferredAddTimeoutTests.test_errbackAddedBeforeTimeoutSuppressesCancellation.<locals>.errbackM  s   ø€ àˆJØ�F‰F”5×'Ñ'Õ(r=   rÔ  rÕ  rÞ  )r,   r!   r\   rX  r:  rs  r0   rb   r   r   r/  r¬  s       @r:   Ú4test_errbackAddedBeforeTimeoutSuppressesCancellationÚLDeferredAddTimeoutTests.test_errbackAddedBeforeTimeoutSuppressesCancellationA  s‹   ø€ ô “ˆÜ$›Jˆàˆ
÷	)ð
 	
�‰�WÔØ	�‰�R˜Ôà�‰�bÔàÑ%Ð%Ð%Ø×Ñ˜j¬'Ô2Ø×Ñ˜j×.Ñ.´×0DÑ0DÔEà×Ñ˜QÕr=   c                ó€  ^• [        5       n[        5       nSmSU4S jjnUR                  U5        UR                  SU[        5        UR                  S5        Tc   eU R                  T[        5        U R                  TR                  [        R                  5        U R                  SU R                  U5      5        g)zÚ
An errback added before a timeout is added with a custom
timeout function errbacks with a L{defer.CancelledError} when
the timeout fires.  The timeout function runs if the errback
returns the L{defer.CancelledError}.
Nc                ó   >• U mU $ r4   rF   r¨  s    €r:   rÆ   ÚMDeferredAddTimeoutTests.test_errbackAddedBeforeTimeoutCustom.<locals>.errbacki  rª  r=   rÔ  rÕ  rO  r«  ©r,   r!   r\   rX  rR  r:  rs  r0   rb   r   r   r^   r/  r¬  s       @r:   Ú$test_errbackAddedBeforeTimeoutCustomÚ<DeferredAddTimeoutTests.test_errbackAddedBeforeTimeoutCustom]  sš   ø€ ô “ˆÜ$›Jˆàˆ
÷	ð
 	
�‰�WÔØ	�‰�R˜¤Ô.à�‰�bÔàÑ%Ð%Ð%Ø×Ñ˜j¬'Ô2Ø×Ñ˜j×.Ñ.´×0DÑ0DÔEà×Ñ˜ t×';Ñ';¸AÓ'>Õ?r=   c                ó€  ^• [        5       n[        5       nSmSU4S jjnUR                  U5        UR                  SU[        5        UR                  S5        Tc   eU R                  T[        5        U R                  TR                  [        R                  5        U R                  SU R                  U5      5        g)zÝ
An errback added before a timeout is added with a custom
timeout function errbacks with a L{defer.CancelledError} when
the timeout fires.  The timeout function runs if the errback
suppresses the L{defer.CancelledError}.
Nc                ó
   >• U mg r4   rF   r¨  s    €r:   rÆ   ÚcDeferredAddTimeoutTests.test_errbackAddedBeforeTimeoutSuppressesCancellationCustom.<locals>.errback…  s   ø€ à‰Jr=   rÔ  rÕ  rO  rÞ  r·  r¬  s       @r:   Ú:test_errbackAddedBeforeTimeoutSuppressesCancellationCustomÚRDeferredAddTimeoutTests.test_errbackAddedBeforeTimeoutSuppressesCancellationCustomy  sš   ø€ ô “ˆÜ$›Jˆàˆ
÷	ð 	
�‰�WÔØ	�‰�R˜¤Ô.à�‰�bÔàÑ%Ð%Ð%Ø×Ñ˜j¬'Ô2Ø×Ñ˜j×.Ñ.´×0DÑ0DÔEà×Ñ˜ t×';Ñ';¸AÓ'>Õ?r=   c                ó   ^^• [        5       nSm[        U4S j5      nSmSU4S jjnUR                  U5        UR                  SU5        UR	                  S5        U R                  TT5        U R                  TU R                  U5      5        g)zú
Given a deferred with a cancellation function that resumes the
callback chain, a callback that is added to the deferred
before a timeout is added to runs when the timeout fires.  The
deferred completes successfully, without a
L{defer.TimeoutError}.
rV  c                ó&   >• U R                  T5      $ r4   rO   ©rZ  rV  s    €r:   r  ÚSDeferredAddTimeoutTests.test_callbackAddedToCancelerBeforeTimeout.<locals>.<lambda>ž  ó   ø€ ¨a¯j©j¸Ô.Ar=   Nc                ó   >• U mU $ r4   rF   ©rb   r^  s    €r:   rP   ÚSDeferredAddTimeoutTests.test_callbackAddedToCancelerBeforeTimeout.<locals>.callback¢  ó   ø€ àˆKØˆLr=   rÔ  rÕ  ©rb   rË   r?   rË   )r,   r!   rª   rX  r:  r^   rr   r/  ©rc   r  rZ  rP   r^  rV  s       @@r:   Ú)test_callbackAddedToCancelerBeforeTimeoutÚADeferredAddTimeoutTests.test_callbackAddedToCancelerBeforeTimeout”  sw   ù€ ô “ˆØˆÜ#Ô$AÓBˆàˆ÷	ð
 	
�‰�hÔØ	�‰�R˜Ôà�‰�bÔà×Ñ˜ gÔ.à�‰�g˜t×3Ñ3°AÓ6Õ7r=   c                ó&  ^^• [        5       nSm[        U4S j5      nSmS	U4S jjnUR                  U5        UR                  SU[        S9  UR                  S5        U R                  TT5        U R                  SU R                  U5      5        g)
a,  
Given a deferred with a cancellation function that resumes the
callback chain, a callback that is added to the deferred
before a timeout is added to runs when the timeout fires.  The
deferred completes successfully, without a
L{defer.TimeoutError}.  The timeout's custom timeout function
also runs.
rV  c                ó&   >• U R                  T5      $ r4   rO   rÁ  s    €r:   r  ÚYDeferredAddTimeoutTests.test_callbackAddedToCancelerBeforeTimeoutCustom.<locals>.<lambda>»  rÃ  r=   Nc                ó   >• U mU $ r4   rF   rÅ  s    €r:   rP   ÚYDeferredAddTimeoutTests.test_callbackAddedToCancelerBeforeTimeoutCustom.<locals>.callback¿  rÇ  r=   rÔ  ri  rÕ  rO  rÈ  )r,   r!   rª   rX  rR  r:  r^   r/  rÉ  s       @@r:   Ú/test_callbackAddedToCancelerBeforeTimeoutCustomÚGDeferredAddTimeoutTests.test_callbackAddedToCancelerBeforeTimeoutCustom°  s}   ù€ ô “ˆØˆÜ#Ô$AÓBˆàˆ÷	ð
 	
�‰�hÔØ	�‰�R˜´ˆÑ>à�‰�bÔà×Ñ˜ gÔ.à×Ñ˜ t×';Ñ';¸AÓ'>Õ?r=   rF   Nr‰   )rH   rI   rJ   rK   rj   rY  rf  rm  rx  r}  r�  r…  r‹  r‘  rš  rŸ  r¤  r­  r²  r¸  r½  rÊ  rÑ  rL   rF   r=   r:   rT  rT  ø  sm   † ñô	:ô+ôB +ôD!+ôF"+ôH4ô@ô"Fô&ô"!+ôF!+ôF@ô4ô8 ô8@ô8@ô68÷8@r=   rT  c                  ó@   • \ rS rSrSrS	S jrS	S jrS	S jrS	S jrSr	g)
ÚEnsureDeferredTestsiÎ  z
Tests for L{ensureDeferred}.
c                óP   • [        5       n[        U5      nU R                  X5        g)z;
L{ensureDeferred} will pass through a Deferred unchanged.
N)r!   r*   rr   r‚  s      r:   Útest_passesThroughDeferredsÚ/EnsureDeferredTests.test_passesThroughDeferredsÓ  s!   € ô &›ZˆÜ˜BÓˆØ�‰�bÕr=   c                óŒ   • U R                  [        R                  5         [        S5        SSS5        g! , (       d  f       g= f)zZ
Passing L{ensureDeferred} a non-coroutine and a non-Deferred will
raise a L{ValueError}.
Ú	somethingN)rC  r   rD  r*   r”   s    r:   Ú'test_willNotAllowNonDeferredOrCoroutineÚ;EnsureDeferredTests.test_willNotAllowNonDeferredOrCoroutineÛ  s,   € ð
 ×Ñœu×7Ñ7Õ8Ü˜;Ô'÷ 9×8Ö8ús	    5µ
Ac                ó  • SS jnU" 5       nU R                  U[        R                  5        [        U5      n[	        U[
        [           5        U R                  U[
        5        U R                  U5      nU R                  US5        g)z=
L{ensureDeferred} will turn a coroutine into a L{Deferred}.
c               “  óR   #   • [         R                  " S5      n U I S h  v•N nU$  N7f©NrÒ  rÆ  ©rZ  r±  s     r:   rÎ  Ú=EnsureDeferredTests.test_ensureDeferredCoroutine.<locals>.runè  s$   é € Ü—’˜eÓ$ˆAØ—'ˆCØˆJñ ùó   ‚'ž%Ÿ'rÒ  N)r?   rË   )	rs  ÚtypesÚCoroutineTyper*   r   r!   rË   r/  r^   ©rc   rÎ  r}  rZ  r±  s        r:   Útest_ensureDeferredCoroutineÚ0EnsureDeferredTests.test_ensureDeferredCoroutineã  ór   € ô
	ñ ‹EˆØ×Ñ˜a¤×!4Ñ!4Ô5ô ˜1ÓˆÜ�A”x¤‘}Ô%Ø×Ñ˜a¤Ô*ð ×"Ñ" 1Ó%ˆØ×Ñ˜˜eÕ$r=   c                ó  • SS jnU" 5       nU R                  U[        R                  5        [        U5      n[	        U[
        [           5        U R                  U[
        5        U R                  U5      nU R                  US5        g)zH
L{ensureDeferred} will turn a yield-from coroutine into a L{Deferred}.
c               3  óR   #   • [         R                  " S5      n U  S h  v•N nU$  N7frÞ  rÆ  rß  s     r:   rÎ  Ú=EnsureDeferredTests.test_ensureDeferredGenerator.<locals>.runÿ  s$   é € Ü—’˜eÓ$ˆAØ—,ˆCØˆJñ ùrá  rÒ  N)r?   z#Generator[Deferred[str], None, str])	rs  râ  ÚGeneratorTyper*   r   r!   rË   r/  r^   rä  s        r:   Útest_ensureDeferredGeneratorÚ0EnsureDeferredTests.test_ensureDeferredGeneratorú  rç  r=   rF   Nr‰   )
rH   rI   rJ   rK   rj   rÖ  rÚ  rå  rì  rL   rF   r=   r:   rÔ  rÔ  Î  s   † ñôô(ô%÷.%r=   rÔ  c                  ó"   • \ rS rSrSrSS jrSrg)ÚTimeoutErrorTestsi  z)
L{twisted.internet.defer} timeout code.
c                óZ  • [        5       n[        R                  " U5        U R                  U[        R                  5        U R                  U R                  /5      nU R                  [        U5      S5        U R                  US   S   [        5        U R                  US   S   S5        g)z2
L{twisted.internet.defer.timeout} is deprecated.
rZ   r   rº   r»   z~twisted.internet.defer.timeout was deprecated in Twisted 17.1.0; please use twisted.internet.defer.Deferred.addTimeout insteadN)r!   r   r!  r&  r'  r½   Útest_deprecatedTimeoutr^   r_   rr   r¾   )rc   rR   ÚwarningsShowns      r:   rñ  Ú(TimeoutErrorTests.test_deprecatedTimeout  s•   € ô &.£ZˆÜ�Š�hÔØ×Ñ˜8¤U×%7Ñ%7Ô8Ø×*Ñ*¨D×,GÑ,GÐ+HÓIˆØ×Ñœ˜]Ó+¨QÔ/Ø�‰�m AÑ& zÑ2Ô4FÔGØ×ÑØ˜!Ñ˜YÑ'ðMõ	
r=   rF   Nr‰   )rH   rI   rJ   rK   rj   rñ  rL   rF   r=   r:   rï  rï    s   † ñ÷
r=   rï  c                óZ   • U R                  U R                  5        U R                  5         g)zæ
Tickle an asyncio event loop to call all of the things scheduled with
call_soon, inasmuch as this can be done via the public API.

@param loop: The asyncio event loop to flush the previously-called
    C{call_soon} entries from.
N)Ú	call_soonÚstopÚrun_forever©Úloops    r:   ÚcallAllSoonCallsrú  (  s    € ð 	‡N�N�4—9‘9ÔØ×ÑÕr=   c                  ód   • \ rS rSrSS jrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrS
rg)ÚDeferredFutureAdapterTestsi4  c                óP   • [        5       nU R                  UR                  5        U$ )zE
Create a new event loop that will be closed at the end of the test.
)Ú_new_event_loopr‘   Úcloserº  s     r:   ÚnewLoopÚ"DeferredFutureAdapterTests.newLoop5  s!   € ô !Ó"ˆØ�‰˜Ÿ™Ô%Øˆr=   c                óT  • [        5       nU R                  5       nUR                  U5      nU R                  UR	                  5       S5        UR                  S5        [        U5        U R                  U R                  U5      S5        U R                  UR                  5       S5        g)z_
L{Deferred.asFuture} returns a L{asyncio.Future} which fires when
the given L{Deferred} does.
FrŸ  N)	r!   r   ÚasFuturer^   r  rP   rú  r/  rt   )rc   rZ  rù  ÚaFutures       r:   Útest_asFutureÚ(DeferredFutureAdapterTests.test_asFuture=  s   € ô
 $›:ˆØ�|‰|‹~ˆØ—*‘*˜TÓ"ˆØ×Ñ˜Ÿ™›¨Ô/Ø	�
‰
�2ŒÜ˜ÔØ×Ñ˜×-Ñ-¨aÓ0°$Ô7Ø×Ñ˜Ÿ™Ó)¨2Õ.r=   c                óL  ^• SmSU4S jjn[        U5      nU R                  5       nUR                  U5      nUR                  5         [	        U5        U R                  T5        U R                  U R                  U5      S5        U R                  [        UR                  5        g)zo
L{Deferred.asFuture} returns a L{asyncio.Future} which, when
cancelled, will cancel the original L{Deferred}.
Fc                ó
   >• Smg r¬  rF   )Údprimerd  s    €r:   ÚcancelerÚFDeferredFutureAdapterTests.test_asFutureCancelFuture.<locals>.cancelerS  s   ø€ à‰Fr=   N©r	  rL  r?   r„   )r!   r   r  r&  rú  r`   r^   r/  rC  r   rt   )rc   r
  rZ  rù  r  rd  s        @r:   Útest_asFutureCancelFutureÚ4DeferredFutureAdapterTests.test_asFutureCancelFutureK  s�   ø€ ð ˆ÷	ô % XÓ.ˆØ�|‰|‹~ˆØ—*‘*˜TÓ"ˆØ�‰ÔÜ˜ÔØ�‰˜ÔØ×Ñ˜×-Ñ-¨aÓ0°$Ô7Ø×Ñœ.¨'¯.©.Õ9r=   c                ó  • SS jn[        U5      nU R                  5       nUR                  U5      nUR                  5         [	        U5        U R                  U R                  U5      S5        U R                  [        UR                  5        g)z²
While Futures don't support succeeding in response to cancellation,
Deferreds do; if a Deferred is coerced into a success by a Future
cancellation, that should just be ignored.
c                ó&   • U R                  S5        g )Nr¡  rO   )r	  s    r:   r
  ÚGDeferredFutureAdapterTests.test_asFutureSuccessCancel.<locals>.cancelerg  s   € Ø�O‰O˜AÕr=   Nr  )
r!   r   r  r&  rú  r^   r/  rC  r   rt   )rc   r
  rZ  rù  r  s        r:   Útest_asFutureSuccessCancelÚ5DeferredFutureAdapterTests.test_asFutureSuccessCancel`  sm   € ô	ô % XÓ.ˆØ�|‰|‹~ˆØ—*‘*˜TÓ"ˆØ�‰ÔÜ˜ÔØ×Ñ˜×-Ñ-¨aÓ0°$Ô7Ø×Ñœ.¨'¯.©.Õ9r=   c                ó  • [        5       n[        [        5       5      nU R                  5       nUR	                  U5      n[        U5        UR                  U5        [        U5        U R                  [        UR                  5        g)zh
L{Deferred.asFuture} makes a L{asyncio.Future} fire with an
exception when the given L{Deferred} does.
N)	r!   r0   rr  r   r  rú  rÆ   rC  rt   )rc   rZ  Ú
theFailurerù  Úfutures        r:   Útest_asFutureFailureÚ/DeferredFutureAdapterTests.test_asFutureFailurer  sc   € ô
 %›JˆÜÔ.Ó0Ó1ˆ
Ø�|‰|‹~ˆØ—‘˜DÓ!ˆÜ˜ÔØ	�	‰	�*ÔÜ˜ÔØ×ÑÔ+¨V¯]©]Õ;r=   c                óþ   • U R                  5       n[        US9n[        R                  " U5      nU R	                  U5        UR                  S5        [        U5        U R                  U R                  U5      S5        g)z`
L{Deferred.fromFuture} returns a L{Deferred} that fires
when the given L{asyncio.Future} does.
rø  r�  N)	r   r   r!   Ú
fromFuturerB  Ú
set_resultrú  r^   r/  )rc   rù  r  rZ  s       r:   Útest_fromFutureÚ*DeferredFutureAdapterTests.test_fromFuture€  sh   € ð
 �|‰|‹~ˆÜ%¨4Ñ0ˆÜ×Ò Ó(ˆØ×Ñ˜AÔØ×Ñ˜1ÔÜ˜ÔØ×Ñ˜×-Ñ-¨aÓ0°!Õ4r=   c                ó   • U R                  5       n[        US9n[        R                  " U5      nUR	                  5         [        U5        U R                  [        UR                  5        U R                  U5      R                  [        5        g)z‚
L{Deferred.fromFuture} makes a L{Deferred} fire with
an L{asyncio.CancelledError} when the given
L{asyncio.Future} is cancelled.
rø  N)r   r   r!   r  r&  rú  rC  r   rt   r'  rà  ©rc   rù  Ú	cancelledrZ  s       r:   Útest_fromFutureFutureCancelledÚ9DeferredFutureAdapterTests.test_fromFutureFutureCancelled�  sl   € ð �|‰|‹~ˆÜ"(¨dÑ"3ˆ	Ü×Ò 	Ó*ˆØ×ÑÔÜ˜ÔØ×Ñœ.¨)×*:Ñ*:Ô;Ø×Ñ˜QÓ×$Ñ$¤^Õ4r=   c                ó`  • U R                  5       n[        US9n[        R                  " U5      nUR	                  5         [        U5        U R                  UR                  5       S5        U R                  [        UR                  5        U R                  U5      R                  [        5        g)zv
L{Deferred.fromFuture} makes a L{Deferred} which, when
cancelled, cancels the L{asyncio.Future} it was created from.
rø  TN)r   r   r!   r  r&  rú  r^   r   rC  r   rt   r'  rà  r  s       r:   Ú test_fromFutureDeferredCancelledÚ;DeferredFutureAdapterTests.test_fromFutureDeferredCancelled›  s‚   € ð
 �|‰|‹~ˆÜ"(¨dÑ"3ˆ	Ü×Ò 	Ó*ˆØ	�‰Œ
Ü˜ÔØ×Ñ˜×,Ñ,Ó.°Ô5Ø×Ñœ.¨)×*:Ñ*:Ô;Ø×Ñ˜QÓ×$Ñ$¤^Õ4r=   rF   N)r?   r   r‰   )rH   rI   rJ   rK   r   r  r  r  r  r  r!  r$  rL   rF   r=   r:   rü  rü  4  s*   † ôô/ô:ô*:ô$<ô5ô5÷5r=   rü  c                  ón   • \ rS rSrS
S jrS
S jr\S
S j5       r\S
S j5       r\S
S j5       r	S
S jr
Srg	)ÚCoroutineContextVarsTestsiª  c                óà  ^ ^^^^^• [        5       m[        R                  " S5      mTR                  S5        [	        5       mTR                  U4S j5        [	        5       mTR                  U4S j5        TR                  S 5        [        R                  SUU4S jj5       m[        T[        / [        S   4   5        [        R                  SUUUU UU4S jj5       n[        U[        / [        [        S	      4   5        TR                  S
5        U" 5       nTR                  S5        TR                  S5        TR                  S5        T R                  T R                  U5      S	5        g)z�
When an inlineCallbacks function is called, the context is taken from
when it was first called. When it resumes, the same context is applied.
ÚtestvarrZ   c                ó&   >• TR                  S5      $ ra  ©Úset©ro  Úvars    €r:   r  ÚDCoroutineContextVarsTests.test_withInlineCallbacks.<locals>.<lambda>·  ó   ø€ ¨s¯w©w°q¬zr=   c                ó&   >• TR                  S5      $ ©Né   r+  r-  s    €r:   r  r/  º  ó   ø€ ¸¿¹À¼
r=   c                ó   • SS-  $ rm  rF   rn  s    r:   r  r/  »  ó   € ¸¸Aºr=   c               3  ó†   >#   • [        5       n TR                  SU R                  S5        U v •  TR                  S5        g 7f©NrZ   Trb  ©r!   r/  rP   r,  ©rZ  r  r.  s    €€r:   ÚyieldingDeferredÚLCoroutineContextVarsTests.test_withInlineCallbacks.<locals>.yieldingDeferred½  s1   øé € ä'›zˆAØ�O‰O˜A˜qŸz™z¨4Ô0ØŠGØ�G‰G�A�Jùs   ƒ>ANc               3  óL  >#   • TR                  TR                  5       S5        [        R                  " S5      v •  TR                  TR                  5       S5        T R	                  STR
                  S5        Tv •  TR                  TR                  5       S5        T R	                  STR
                  S5         Tv •  [        S5      e! [         a#    TR                  TR                  5       S5         Of = fT" 5       v •  TR                  TR                  5       S5        g7f)Nrá   rZ   Tú???? should have failed©r^   r  r   rW  r/  rP   r  )r  ÚmutatingDeferredÚmutatingDeferredThatFailsrc   r.  r;  s   €€€€€€r:   ÚtestFunctionÚHCoroutineContextVarsTests.test_withInlineCallbacks.<locals>.testFunctionÇ  sû   øé € ð ×Ñ˜SŸW™W›Y¨Ô*ô —-’- Ó"Ò"ð ×Ñ˜SŸW™W›Y¨Ô*ð �O‰O˜AÐ/×8Ñ8¸$Ô?Ø"Ò"ð ×Ñ˜SŸW™W›Y¨Ô*ð �O‰O˜AÐ8×AÑAÀ4ÔHð;Ø/Ò/ô  Ð 9Ó:Ð:øô ó /Ø× Ñ  §¡£¨AÖ.ð/úñ #Ó$Ò$Ø×Ñ˜SŸW™W›Y¨Ô*àùs*   ƒB7D$Â;C
 Â?D$Ã
*C7Ã4D$Ã6C7Ã7-D$Trá   ©r?   z#Generator[Deferred[Any], Any, None])r?   z,Generator[Deferred[Any], Any, Literal[True]])r,   ÚcontextvarsÚ
ContextVarr,  r!   rª   r   ÚinlineCallbacksr   r	   r   r:  r^   r/  )rc   rB  rZ  r  r@  rA  r.  r;  s   `  @@@@@r:   Útest_withInlineCallbacksÚ2CoroutineContextVarsTests.test_withInlineCallbacks«  s.  ý€ ô
 “ˆä+6×+AÒ+AÀ)Ó+LˆØ�‰�Œ
ô ,4«:ÐØ×$Ñ$Ô%9Ô:ä3;³:Ð!Ø!×-Ñ-Ô.BÔCØ!×-Ñ-©oÔ>ä	×	Ñ	÷	ó 
ð	ô 	Ð$¤h¨r´8¸D±>Ð/AÑ&BÔCô 
×	Ñ	÷"	ó "	ó 
ð"	ôH 	�L¤(¨2¬x¼À¹Ñ/FÐ+FÑ"GÔHà�‰�Œ
Ù‹Nˆð 	�‰�aÔð 	�‰�aÔð 	�‰�aÔà×Ñ˜×-Ñ-¨aÓ0°$Õ7r=   c                óø   ^ ^^• [        5       m[        R                  " S5      m[        R                  SUU U4S jj5       nTR                  S5        U" 5       nTR                  S5        T R                  U5        g)z|
When an inlineCallbacks function resumes, we should be able to reset() a
contextvar that was set when it was first called.
r)  c               3  ó(  >#   • TR                  S5      n [        5       nTR                  SUR                  S5        Uv •  TR	                  TR                  5       S5        TR                  U 5        TR	                  TR                  5       S5        g 7f)Nrb  rZ   Trá   )r,  r!   r/  rP   r^   r  Úreset)ÚtokenrZ  r  rc   r.  s     €€€r:   r;  ÚQCoroutineContextVarsTests.test_resetWithInlineCallbacks.<locals>.yieldingDeferred  so   øé € ð —G‘G˜A“JˆEô  (›zˆAØ�O‰O˜A˜qŸz™z¨4Ô0ØŠGØ×Ñ˜SŸW™W›Y¨Ô*à�I‰I�eÔà×Ñ˜SŸW™W›Y¨Õ*ùs   ƒBBrá   rZ   NrD  )r,   rE  rF  r   rG  r,  r:  r/  )rc   r;  rZ  r  r.  s   `  @@r:   Útest_resetWithInlineCallbacksÚ7CoroutineContextVarsTests.test_resetWithInlineCallbacksü  sj   ú€ ô
 “ˆä+6×+AÒ+AÀ)Ó+Lˆä	×	Ñ	÷	+ð 	+ó 
ð	+ð 	�‰�Œ
ÙÓˆð 	�‰�aÔØ×Ñ˜QÕr=   c              ƒ  ó  ^#   • [        5       mSnT ISh  v•N   U R                  TR                  5        TR                  5       nUR	                  U4S j5        U R                  TR                  5        U R                  UR                  5        SSS5      ISh  v•N   U R                  UR                  5        UI Sh  v•N   U R                  TR                  5        g NË NG! , ISh  v•N  (       d  f       N\= f N>7f)zA
L{DeferredLock} can be used as an asynchronous context manager.
Nc                ó$   >• TR                  5       $ r4   ©rÍ  )ro  rÏ  s    €r:   r  Ú>CoroutineContextVarsTests.test_asyncWithLock.<locals>.<lambda>&  s   ø€  D§L¡L¤Nr=   )r$   r`   rÌ  rË  rª   r0  rd  )rc   rZ  rÏ  s     @r:   Útest_asyncWithLockÚ,CoroutineContextVarsTests.test_asyncWithLock  s¦   øé € ô
 ‹~ˆØˆß’4Ø�O‰O˜DŸK™KÔ(Ø—‘“ˆAØ�M‰MÔ2Ô3Ø�O‰O˜DŸK™KÔ(Ø×Ñ˜QŸX™XÔ&÷ —4ð 	�‰˜Ÿ™Ô!Ø�ˆØ×Ñ˜Ÿ™Õ%÷ —4—4’4úñ 	ùsQ   ƒD–C"—DšA7C&ÂDÂC$Â$DÃD Ã!DÃ$DÃ&C=Ã,C/Ã-C=Ã9Dc              ƒ  óÂ  ^#   • [        S5      mT ISh  v•N   U R                  TR                  S5        T ISh  v•N   U R                  TR                  S5        TR                  5       nTR                  5       nU R                  TR                  S5        U R	                  UR
                  5        U R                  UR
                  5        SSS5      ISh  v•N   U R                  TR                  S5        U R	                  WR
                  5        WR                  U4S j5        UR                  U4S j5        UI Sh  v•N   UI Sh  v•N   U R                  TR                  S5        SSS5      ISh  v•N   U R                  TR                  S5        g GNˆ GNd NÈ! , ISh  v•N  (       d  f       NÝ= f Ny Nq NG! , ISh  v•N  (       d  f       N\= f7f)zF
L{DeferredSemaphore} can be used as an asynchronous context
manager.
rb  Nrá   rZ   r   c                ó$   >• TR                  5       $ r4   rS  ©ro  rï  s    €r:   r  ÚCCoroutineContextVarsTests.test_asyncWithSemaphore.<locals>.<lambda>@  ó   ø€  S§[¡[¤]r=   c                ó$   >• TR                  5       $ r4   rS  rY  s    €r:   r  rZ  A  r[  r=   )r&   r^   ÚtokensrË  r`   rd  r0  rª   )rc   r	  r  rï  s      @r:   Útest_asyncWithSemaphoreÚ1CoroutineContextVarsTests.test_asyncWithSemaphore-  s8  øé € ô   Ó"ˆç’3Ø×Ñ˜SŸZ™Z¨Ô+ß’sØ× Ñ  §¡¨QÔ/Ø—[‘[“]�Ø—[‘[“]�Ø× Ñ  §¡¨QÔ/Ø—‘ §	¡	Ô*Ø× Ñ  §¡Ô+÷ —sð ×Ñ˜SŸZ™Z¨Ô+Ø�O‰O˜BŸI™IÔ&Ø�N‰NÔ2Ô3Ø�N‰NÔ2Ô3Ø�HˆHØ�HˆHØ×Ñ˜SŸZ™Z¨Ô+÷ —3ð  	×Ñ˜Ÿ™ QÕ'ò! ç—s—s“súñ Ù÷ —3—3�3üsª   ƒG•F–G™#G¼F ½GÁ BF%ÃGÃF#ÃA*GÅF?Å	GÅGÅ GÅ0GÅ;GÅ<"GÆ GÆ#GÆ%F<	Æ+F.Æ,F<	Æ8GÇGÇGÇGÇGÇGÇGc              ƒ  óT  #   • [        5       nU R                  [        S5         U ISh  v•N   U R                  UR                  5        [        S5      e N*! , ISh  v•N  (       d  f       O= f SSS5        O! , (       d  f       O= fU R                  UR                  5        g7f)z_
C{DeferredLock} correctly propagates exceptions when
used as an asynchronous context manager.
zsome specific exceptionN)r$   ÚassertRaisesRegexr  r`   rÌ  r0  r5  s     r:   Útest_asyncWithLockExceptionÚ5CoroutineContextVarsTests.test_asyncWithLockExceptionG  so   é € ô ‹~ˆØ×#Ñ#¤IÐ/HÕIß’tØ—‘ §¡Ô,ÜÐ 9Ó:Ð:÷ —t—t�tú�t÷ J×IÖIúð 	×Ñ˜Ÿ™Õ%ùsI   ‚!B(£A;ªA«A;®'AÁA;ÁA.	ÁA ÁA.	Á*A;Á2	B(Á;
B	Â#B(c                ó(  ^ ^^^^^• [        5       m[        R                  " S5      mTR                  S5        [	        5       mTR                  U4S j5        [	        5       mTR                  U4S j5        TR                  S 5        SUU4S jjmSUUUUU U4S jjnTR                  S5        [        U" 5       5      nTR                  S5        TR                  S5        TR                  S5        T R                  T R                  U5      S	5        g
)z
When a coroutine is called, the context is taken from when it was first
called. When it resumes, the same context is applied.
r)  rZ   c                ó&   >• TR                  S5      $ ra  r+  r-  s    €r:   r  ÚJCoroutineContextVarsTests.test_contextvarsWithAsyncAwait.<locals>.<lambda>`  r0  r=   c                ó&   >• TR                  S5      $ r2  r+  r-  s    €r:   r  rf  c  r4  r=   c                ó   • SS-  $ rm  rF   rn  s    r:   r  rf  d  r6  r=   c               “  ó–   >#   • [        5       n TR                  SU R                  S5        U I S h  v•N   TR                  S5        g  N7fr8  r9  r:  s    €€r:   ÚasyncFuncAwaitingDeferredÚ[CoroutineContextVarsTests.test_contextvarsWithAsyncAwait.<locals>.asyncFuncAwaitingDeferredf  s8   øé € Ü (£
ˆAØ�O‰O˜A˜qŸz™z¨4Ô0Ø�GˆGØ�G‰G�A�Jñ ùs   ƒ-A	°A±A	c               “  óŠ  >#   • TR                  TR                  5       S5        [        R                  " S5      I S h  v•N   TR                  TR                  5       S5        TR	                  STR
                  S5        TI S h  v•N   TR                  TR                  5       S5        TR	                  STR
                  S5         TI S h  v•N   [        S5      e Nž NY N! [         a#    TR                  TR                  5       S5         Of = fT " 5       I S h  v•N    TR                  TR                  5       S5        g7f)Nrá   rZ   r   Tr>  rb  r?  )rj  r  r@  rA  rc   r.  s   €€€€€€r:   rB  ÚNCoroutineContextVarsTests.test_contextvarsWithAsyncAwait.<locals>.testFunctionm  s  øé € à×Ñ˜SŸW™W›Y¨Ô*ô —-’- Ó"×"Ð"ð ×Ñ˜SŸW™W›Y¨Ô*ð �O‰O˜AÐ/×8Ñ8¸$Ô?Ø"×"Ð"ð ×Ñ˜SŸW™W›Y¨Ô*ð �O‰O˜AÐ8×AÑAÀ4ÔHð;Ø/×/Ð/ô  Ð 9Ó:Ð:ñ) #ñ #ñ 0øÜó /Ø× Ñ  §¡£¨AÖ.ð/úñ ,Ó-×-Ñ-Ø×Ñ˜SŸW™W›Y¨Ô*àùse   ƒ:E½C¾AEÂCÂAEÃC" ÃC ÃC" ÃEÃEÃ C" Ã"*DÄEÄDÄEÄDÄ&Erá   TNr‰   )r?   rä   )
r,   rE  rF  r,  r!   rª   r*   r:  r^   r/  )rc   rB  rZ  rj  r  r@  rA  r.  s   `  @@@@@r:   Útest_contextvarsWithAsyncAwaitÚ8CoroutineContextVarsTests.test_contextvarsWithAsyncAwaitT  sØ   ý€ ô
 “ˆä+6×+AÒ+AÀ)Ó+LˆØ�‰�Œ
ô ,4«:ÐØ×$Ñ$Ô%9Ô:ä4<³JÐ!Ø!×-Ñ-Ô.BÔCØ!×-Ñ-©oÔ>÷	ð 	÷!	ô !	ðH 	�‰�Œ
Ü™<›>Ó*ˆð 	�‰�aÔð 	�‰�aÔð 	�‰�aÔà×Ñ˜×-Ñ-¨aÓ0°$Õ7r=   rF   Nr‰   )rH   rI   rJ   rK   rH  rO  rB   rU  r^  rb  rn  rL   rF   r=   r:   r'  r'  ª  sQ   † ôO8ôb ð@ ó&ó ð&ð  ó(ó ð(ð2 ó
&ó ð
&÷I8r=   r'  c                  óT   • \ rS rSrSS jr\R                  " \S5      SS j5       rSr	g)ÚInlineCallbackTestsi   c                ó¢   • S SSU R                   S[        /nU H2  nU R                  [        R                  [        R
                  U5        M4     g)r=  c                ó   • U $ r4   rF   rÐ  s    r:   r  ÚIInlineCallbackTests.test_fromCoroutineRequiresCoroutine.<locals>.<lambda>¨  r@  r=   rZ   TNrA  rE  s      r:   rB  Ú7InlineCallbackTests.test_fromCoroutineRequiresCoroutine¡  rI  r=   rJ  c                óN  • [        5       n[        R                  " U5      nSS jn[        R                  " U" U5      5      nU R                  XR                  U5      5        [        R                  " U5      nAAU R                  U" 5       5        U R                  U" 5       5        g)z¢
Tests that there is no circular dependency when using
L{Deferred.fromCoroutine}, so that the machinery gets cleaned up
immediately rather than waiting for a GC.
c              “  ó   #   • U $ 7fr4   rF   )r;  s    r:   r×  ÚCInlineCallbackTests.test_coroutineNoCircularReference.<locals>.funcÄ  s
   é € ØˆHùs   ‚N)r;  r   r?   r   )r,  rM  rN  r!   r5   r^   r/  r«   )rc   ÚobjÚ
objWeakRefr×  ÚfuncDÚfuncDWeakRefs         r:   Ú!test_coroutineNoCircularReferenceÚ5InlineCallbackTests.test_coroutineNoCircularReference¸  s…   € ô ›ˆÜ—[’[ Ó%ˆ
ô	ô ×&Ò&¡t¨C£yÓ1ˆØ×Ñ˜×2Ñ2°5Ó9Ô:ä—{’{ 5Ó)ˆð Øð 	×Ñ™*›,Ô'Ø×Ñ™,›.Õ)r=   rF   Nr‰   )
rH   rI   rJ   rK   rB  rg  rh  r.   r}  rL   rF   r=   r:   rq  rq     s(   † ôWð. ‡]‚]�5Ð9Ó:ó*ó ;ó*r=   rq  )r9   z0Callable[..., Coroutine[Deferred[Any], Any, _T]]r?   zCallable[..., Deferred[_T]])rR   r˜  r?   r„   )rt  rt  r?   z(tuple[list[int], list[Deferred[object]]])rP  r>   rQ  Úfloatr?   rË   )rù  r   r?   r„   )crj   Ú
__future__r   rE  r@   rp  rÓ  rõ  râ  r1   rg  rÀ   rM  Úasyncior   r   r   r   rþ  Útypingr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   Úhamcrestr   r   r   Ú
hypothesisr   Úhypothesis.strategiesr   Útyping_extensionsr   Útwisted.internetr   r   Útwisted.internet.deferr    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   Útwisted.internet.taskr,   Útwisted.pythonr-   Útwisted.python.compatr.   Útwisted.python.failurer0   Útwisted.trialrB   r  rD   rS   rT   rW   r[   rl   ÚSynchronousTestCaser‹   rL  rv  rx  r”  rª  r  r]  r§  r¶  r  rR  rT  rÔ  rï  rú  rü  r'  rq  rF   r=   r:   Ú<module>r�     s1  ðñõ #ã Û Û 	Û 	Û Û Û Û Û ÷ó ÷÷ ÷ ÷ ó ÷& 2Ñ 1Ý Ý *Ý )ç +÷÷ ÷ ó õ (Ý Ý 'Ý *Ý "ðØ7ðà ôô	�9ô 	ô)ñ �m¨9Ñ5€÷4ñ 4ô,*M�×!Ñ!ô *MôZU9�H×0Ñ0Ð2Gô U9÷p4ñ ôô&~7�×,Ñ,ô ~7ôB;$�h×2Ñ2ô ;$ô|L$˜×5Ñ5ô L$ô^GI˜X×9Ñ9ô GIôTc3ˆx×+Ñ+ô c3ôLE˜X×9Ñ9ô Eô"A'˜8×7Ñ7Ð9Nô A'ôHz= (×"3Ñ"3ô z=ôzôS@˜h×:Ñ:ô S@ôlA%˜(×+Ñ+ô A%ôH
˜×)Ñ)Ð+@ô 
ô,	ôs5 ×!2Ñ!2ô s5ôls8 × 1Ñ 1ô s8ôl3*˜(×6Ñ6õ 3*r=   