+
    üÐjc<  ã                  ó   a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIHtHt ^ RI	H
t
 ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHtHt ^ R
IHtHtHt ]! R4      t. tR]R&   ]
! ]P:                  4       ! R R]4      4       tR# )z4
Things likely to be used by writers of unit tests.
)ÚannotationsN)ÚCallableÚList)Úimplementer)Ú	ParamSpec)ÚdeferÚutils)Ú_T)Úfailure)ÚitrialÚutil)ÚFailTestÚSkipTestÚSynchronousTestCaseÚ_Pz
List[None]Ú_wait_is_runningc                  óÖ   a € ] tR t^!tRtRV 3R lltR R lt]tR tR t	R t
R tR	 tR
 t]P                  R 4       tR tR tR tR tR tR tR V 3R lltR tR t]3R ltRtV ;t# )ÚTestCasea  
A unit test. The atom of the unit testing universe.

This class extends L{SynchronousTestCase} which extends C{unittest.TestCase}
from the standard library. The main feature is the ability to return
C{Deferred}s from tests and fixture methods and to have the suite wait for
those C{Deferred}s to fire.  Also provides new assertions such as
L{assertFailure}.

@ivar timeout: A real number of seconds. If set, the test will
raise an error if it takes longer than C{timeout} seconds.
If not set, util.DEFAULT_TIMEOUT_DURATION is used.
c                óL   <€ \         SV `  V4       ^ RIHp W n        RV n        R# )ag  
Construct an asynchronous test case for C{methodName}.

@param methodName: The name of a method on C{self}. This method should
be a unit test. That is, it should be a short method that calls some of
the assert* methods. If C{methodName} is unspecified,
L{SynchronousTestCase.runTest} will be used as the test method. This is
mostly useful for testing Trial.
©ÚreactorFN)ÚsuperÚ__init__Útwisted.internetr   Ú_twistedPrivateSchedulerÚ_twistedPrivateNeedsTearDown)ÚselfÚ
methodNamer   Ú	__class__s   && €Ú:/usr/lib/python3/dist-packages/twisted/trial/_asynctest.pyr   ÚTestCase.__init__1   s)   ø€ ô 	‰Ñ˜Ô$õ 	-ð )0Ô%ð -2ˆÖ)ó    c               ó$   € V ^8„  d   QhRRRRRR/# )é   Údeferredzdefer.Deferred[_T]ÚexpectedFailuresztype[BaseException]Úreturn© )Úformats   "r   Ú__annotate__ÚTestCase.__annotate__I   s$   € ÷ /ñ /Ø*ð/Ø?Rð/à	ñ/r!   c                óB   a a€ V 3R lpVV 3R lpVP                  W44      # )z¶
Fail if C{deferred} does not errback with one of C{expectedFailures}.
Returns the original Deferred with callbacks added. You will need
to return this Deferred from your test case.
c                ó.   <€ SP                  R V : 24      h)z$did not catch an error, instead got )ÚfailureException)Úignorer   s   &€r   Ú_cbÚ#TestCase.assertFailure.<locals>._cbR   s    ø€ Ø×'Ñ'Ø6°v±jÐAóð r!   c                ó    <€ V P                   ! S!  '       d   V P                  # R P                  S\        V 4      4      pSP	                  V4      h)z
Expected: {!r}
Got:
{})ÚcheckÚvaluer(   Ústrr-   )r
   Úoutputr%   r   s   & €€r   Ú_ebÚ#TestCase.assertFailure.<locals>._ebW   sI   ø€ Ø�}Š}Ð.×/Ð/Ø—}‘}Ð$à5×<Ñ<Ø$¤c¨'£ló�ð ×+Ñ+¨FÓ3Ð3r!   )ÚaddCallbacks)r   r$   r%   r/   r6   s   f&j  r   ÚassertFailureÚTestCase.assertFailureI   s    ù€ õ	ö
	4ð ×$Ñ$ SÓ.Ð.r!   c                	ó  a aaaa€ S P                  4       oVVV V3R  lp\        P                  ! V\        P                  ! \
        R7      4      p\        P                  ! V4      '       d1   \        RP                  V4      4      p\        P                  ! V4      # \        P                  ! \        P                  S P                  4       V4      pS P                  P!                  SWF4      oVP#                  V3R l4       V# )c                ó¶  <€ \         P                  ! S: R S RS R24      p\        P                  ! V4      p V P	                  V4       R#   \         P
                   dx    SP                  P                  4        RSn        SP                  4       pTe-   TP                  T4      '       d   SP                  SY#4        R# SP                  ST4        R# i ; i)z (z) still running at z secsTN)r   ÚTimeoutErrorr
   ÚFailureÚerrbackÚAlreadyCalledErrorr   ÚcrashÚ	_timedOutÚgetTodoÚexpectedÚaddExpectedFailureÚaddError)ÚdÚeÚfÚtodoÚfuncDescriptionÚresultr   Útimeouts   &   €€€€r   Ú	onTimeoutÚ TestCase._run.<locals>.onTimeoutg   s¸   ø€ Ü×"Ò"Ø‘(˜"˜_Ð-Ð-@ÀÀ	ÈÐOóˆAô —’ Ó"ˆAð-Ø—	‘	˜!–øÜ×+Ñ+ô 
-ð ×-Ñ-×3Ñ3Ô5Ø!%�”Ø—|‘|“~�ØÒ#¨¯©°a×(8Ò(8Ø×-Ñ-¨d°A×<à—O‘O D¨!×,ð
-ús   ¹A ÁA CÂ-CÃCÃC©Úcategoryz9{!r} is a generator function and therefore will never runc                óh   <€ SP                  4       ;'       d    SP                  4       ;'       g    T # ©N)ÚactiveÚcancel)ÚxÚcalls   &€r   Ú<lambda>ÚTestCase._run.<locals>.<lambda>‰   s$   ø€ ˜DŸK™K›M×;Ð;¨d¯k©k«m×@Ð@¸qÐ@r!   )Ú
getTimeoutr   ÚsuppressWarningsr   ÚsuppressÚDeprecationWarningÚinspectÚisgeneratorfunctionÚ	TypeErrorr(   r   ÚfailÚmaybeDeferredÚrunWithWarningsSuppressedÚ_getSuppressr   Ú	callLaterÚaddBoth)	r   ÚfuncrK   rL   rN   ÚexcrG   rW   rM   s	   f&ff   @@r   Ú_runÚTestCase._rund   sÈ   ü€ Ø—/‘/Ó#ˆ÷	-ð 	-ô, ×*Ò*Ø”t—}’}Ô.@ÔAó
ˆ	ô ×&Ò& t×,Ò,ÜØK×RÑRÐSWÓXóˆCô —:’:˜c“?Ð"Ü×ÒÜ×+Ñ+¨T×->Ñ->Ó-@À$ó
ˆð ×,Ñ,×6Ñ6°wÀ	ÓMˆØ	�	‰	Ô@ÔAØˆr!   c                	ó&   € V P                   ! V/ VB # rS   )Úrun)r   ÚargsÚkwargss   &*,r   Ú__call__ÚTestCase.__call__Œ   s   € Ø�xŠx˜Ð( Ñ(Ð(r!   c              ƒ  	ó€  "  €   V P                  V4      G R j  x€L
  V P                  V4      G R j  x€L
   V P                  '       d   V P                  V4      G R j  x€L
  R # R #  LM L6  T P                  T4      G R j  x€L 
  i ; i L+  T P                  '       d   T P                  T4      G R j  x€L 
  i i ; i5irS   )Ú_deferSetUpAndRunÚ_deferRunCleanupsr   Ú_deferTearDown©r   rL   s   &&r   Ú_deferSetUpÚTestCase._deferSetUp�   s¦   é € ð	2ð5Ø×,Ñ,¨VÓ4×4Ð4à×,Ñ,¨VÓ4×4Ñ4à×0×0Ð0Ø×)Ñ)¨&Ó1×1Ò1ñ 1ñ	 5á4ø�d×,Ñ,¨VÓ4×4Ò4úñ 2øð ×0×0Ð0Ø×)Ñ)¨&Ó1×1Ò1ð 1üs|   ‚B>…A+ ™A'šA+ žB ²A)³B ¸B>Á
B>ÁB
ÁB>Á'A+ Á)B Á+BÂ BÂBÂB Â
B>Â'B;Â3B6Â4B;Â;B>c              ƒ  ó\  "  €  V P                  V P                  RV4      G Rj  x€L
  RT n         T P                  \        Y P                  4      T P                  T4      G Rj  x€L
  T P                  4       e"   TP                  Y P                  4       4       R# RT n        R#  L€  \         d7   pTP                  Y P	                  T P                  T4      4        Rp?R# Rp?i\
         dB   pTP                  T \        P                  ! T4      4       TP                  4         Rp?R# Rp?i\         d2   pTP                  T \        P                  ! T4      4        Rp?R# Rp?ii ; i EL  \         d-   pT P#                  \        P                  ! T4      T4       h Rp?ii ; i5i)zS
Execute the setUp and run part of a test. Teardown and cleanups are not executed.
ÚsetUpNT)ri   ry   r   ÚaddSkipÚ_getSkipReasonÚKeyboardInterruptrF   r
   r>   ÚstopÚBaseExceptionr   ÚgetattrÚ_testMethodNamerC   ÚaddUnexpectedSuccessÚ_passedÚ_ebDeferTestMethod©r   rL   rH   s   && r   rr   ÚTestCase._deferSetUpAndRun™   s@  é € ð	Ø—)‘)˜DŸJ™J¨°Ó8×8Ð8ð -1ˆÔ)ð
	Ø—)‘)Ü˜×2Ñ2Ó3°T×5IÑ5IÈ6ó÷ ð ð �|‰|‹~Ò)Ø×+Ñ+¨D·,±,³.ÖAà#�–ñ+ 9øÜô 	Ø�N‰N˜4×!4Ñ!4°T·Z±ZÀÓ!CÔDÝûÜ ô 	Ø�O‰O˜D¤'§/¢/°!Ó"4Ô5Ø�K‰KŒMÝûÜô 	Ø�O‰O˜D¤'§/¢/°!Ó"4Ô5Ýûð	úòøô ô 	Ø×#Ñ#¤G§O¢O°AÓ$6¸Ô?Øûð	üs®   ‚F,„ B' ¤B%¥B' ©F,±3E2 Á$E/Á%5E2 ÂF,ÂE2 Â#F,Â%B' Â'E,Â2+C#ÃF,Ã#E,Ã0E,Ã16D-Ä'F,Ä-E,Ä:E,Ä;&E'Å!F,Å'E,Å,F,Å/E2 Å2F)Å='F$Æ$F)Æ)F,c           	     	óJ  € V P                  4       pVe,   VP                  V4      '       d   VP                  WV4       R # VP                  V P                  \
        4      '       d   VP                  W4       R # VP                  \        4      '       d$   VP                  W4       VP                  4        R # VP                  \        4      '       dA   VP                  W P                  \        W P                  4      VP                  4      4       R # VP                  W4       R # rS   )rC   rD   rE   r2   r-   r   Ú
addFailurer|   rF   r}   r   rz   r{   r   r€   r3   )r   rI   rL   rJ   s   &&& r   rƒ   ÚTestCase._ebDeferTestMethod¸   sÃ   € Ø�|‰|‹~ˆØÒ §¡¨a× 0Ò 0Ø×%Ñ% d¨tÖ4Ø�W‰W�T×*Ñ*¬H×5Ò5Ø×Ñ˜dÖ&Ø�W‰WÔ&×'Ò'Ø�O‰O˜DÔ$Ø�K‰KŽMØ�W‰W”X×ÒØ�N‰NØ×)Ñ)¬'°$×8LÑ8LÓ*MÈqÏwÉwÓWöð �O‰O˜DÖ$r!   c              ƒ  	óŒ  "  €  V P                  V P                  R V4      G Rj  x€L
  R#  L  \         dI   pTP                  T \        P
                  ! T4      4       TP                  4        RT n         Rp?R# Rp?i\         d9   pTP                  T \        P
                  ! T4      4       RT n         Rp?R# Rp?ii ; i5i)ÚtearDownNF)	ri   rŠ   r|   rF   r
   r>   r}   r‚   r~   r„   s   && r   rt   ÚTestCase._deferTearDownÈ   s…   é € ð	!Ø—)‘)˜DŸM™M¨:°vÓ>×>Ô>øÜ ô 	!Ø�O‰O˜D¤'§/¢/°!Ó"4Ô5Ø�K‰KŒMØ ˆD�LŠLûÜô 	!Ø�O‰O˜D¤'§/¢/°!Ó"4Ô5Ø ˆD�LŠLûð	!üsN   ‚C„ - ¤+¥- ©C«- ­C¸=A;Á5CÁ;CÂCÂ	-B<Â6CÂ<CÃCc              #  óŒ  aaa"  € . p\        V P                  4      ^ 8”  dJ   V P                  P                  4       w  ooo V P                  VVV3R lRSP                   2V4      x € Kc  V F  pVP                  W4       RV n
        K  	  R#   \
         d)    TP                  \        P                  ! 4       4        K¸  i ; i5i)zN
Run any scheduled cleanups and report errors (if any) to the result.
object.
c                 ó   <€ S! S / SB # rS   r'   )rm   rg   rn   s   €€€r   rX   Ú,TestCase._deferRunCleanups.<locals>.<lambda>Þ   s   ø€ ™D $Ð1¨&Ò1r!   zcleanup function FN)ÚlenÚ	_cleanupsÚpopri   Ú__name__Ú	ExceptionÚappendr
   r>   rF   r‚   )r   rL   ÚfailuresrI   rm   rg   rn   s   &&  @@@r   rs   ÚTestCase._deferRunCleanupsÓ   s£   úé € ð ˆÜ�$—.‘.Ó! AÔ%Ø!%§¡×!3Ñ!3Ó!5ÑˆD�$˜ð3Ø—i‘iÞ1Ø'¨¯© Ð7Øóô ó ˆAØ�O‰O˜DÔ$Ø ˆDŽLó øô ô 3Ø—‘¤§¢Ó 1×2ð3üs)   …;CÁ(B Á)%CÂ/CÂ=CÃ CÃCc                	óä  €  \         P                  ! W4      P                  4       pV'       g   R V n        T P                  P                  4        F  pTP                  Y4       R T n        K  	  T P                  4        T P                  4        T P                  '       d   TP                  T 4       R# R#   \         d0    TP                  T \        P                  ! 4       4       R T n         L¹i ; i)FN)r   Ú_JanitorÚpostCaseCleanupr‚   r~   rF   r
   r>   Ú	_observerÚ	getErrorsÚflushLoggedErrorsÚ_removeObserverÚ
addSuccess)r   rL   ÚcleanÚerrors   &&  r   Ú_cleanUpÚTestCase._cleanUpé   s·   € ð	!Ü—M’M $Ó/×?Ñ?ÓAˆEßØ$�”ð —^‘^×-Ñ-Ö/ˆEØ�O‰O˜DÔ(Ø ˆDŽLñ 0ð 	×ÑÔ Ø×ÑÔØ�<�<ˆ<Ø×Ñ˜dÖ#ñ øô ô 	!Ø�O‰O˜D¤'§/¢/Ó"3Ô4Ø ˆDŽLð	!ús   ‚3B5 Â57C/Ã.C/c                	ó¾   €  \         P                  ! W4      P                  4        R #   \         d*    TP	                  T \
        P                  ! 4       4        R # i ; irS   )r   r˜   ÚpostClassCleanupr~   rF   r
   r>   ru   s   &&r   Ú_classCleanUpÚTestCase._classCleanUpù   s@   € ð	5Ü�MŠM˜$Ó'×8Ñ8Ö:øÜô 	5Ø�O‰O˜D¤'§/¢/Ó"3×4ð	5ús   ‚$( ¨0AÁAc                ó   a a€ VV 3R lpV# )z}
Create a method which wraps the reactor method C{name}. The new
method issues a deprecation warning and calls the original.
c                 ó‚   <€ \         P                  ! R S: RS: R2^\        R7       SP                  S,          ! V / VB # )zreactor.z8 cannot be used inside unit tests. In the future, using z7 will fail the test and may crash or hang the test run.)Ú
stacklevelrQ   )ÚwarningsÚwarnr]   Ú_reactorMethods)ÚaÚkwÚnamer   s   *,€€r   Ú_Ú&TestCase._makeReactorMethod.<locals>._  s@   ø€ Ü�M‹Mó 26³tð=ð Ü+õð ×'Ñ'¨Ö-¨qÐ7°BÑ7Ð7r!   r'   )r   r¯   r°   s   ff r   Ú_makeReactorMethodÚTestCase._makeReactorMethodÿ   s   ù€ ö	8ð ˆr!   c                óŒ   € / V n         R F6  p\        W4      V P                   V&   \        WV P                  V4      4       K8  	  R# )zË
Deprecate C{iterate}, C{crash} and C{stop} on C{reactor}. That is,
each method is wrapped in a function that issues a deprecation
warning, then calls the original.

@param reactor: The Twisted reactor.
N)rA   Úiterater}   )r¬   r   Úsetattrr²   )r   r   r¯   s   && r   Ú_deprecateReactorÚTestCase._deprecateReactor  s@   € ð  "ˆÔÛ0ˆDÜ)0°Ó)?ˆD× Ñ  Ñ&Ü�G 4×#:Ñ#:¸4Ó#@ÖAó 1r!   c                ór   € V P                   P                  4        F  w  r#\        WV4       K  	  / V n         R# )zu
Restore the deprecated reactor methods. Undoes what
L{_deprecateReactor} did.

@param reactor: The Twisted reactor.
N)r¬   Úitemsr¶   )r   r   r¯   Úmethods   &&  r   Ú_undeprecateReactorÚTestCase._undeprecateReactor  s1   € ð !×0Ñ0×6Ñ6Ö8‰LˆDÜ�G 6Ö*ñ 9à!ˆÖr!   c                ó¦  € ^ RI Hp V P                  V4       RV n         \        P
                  P                  V P                  V4      4      p V P                  V4       V P                  V4       V P                  V4        V P                  V4       R#   T P                  T4       T P                  T4       i ; i  T P                  T4       i ; i)z»
Really run C{setUp}, the test method, and C{tearDown}.  Any of these may
return L{defer.Deferred}s. After they complete, do some reactor cleanup.

@param result: A L{TestResult} object.
r   FN)r   r   r·   rB   r   ÚDeferredÚfromCoroutinerv   Ú_waitr¡   r¥   r¼   )r   rL   r   rG   s   &&  r   Ú_runFixturesAndTestÚTestCase._runFixturesAndTest)  s¥   € õ 	-à×Ñ˜wÔ'ØˆŒð	.Ü—‘×,Ñ,¨T×-=Ñ-=¸fÓ-EÓFˆAð+Ø—
‘
˜1”à—‘˜fÔ%Ø×"Ñ" 6Õ*à×$Ñ$ WÖ-øð —‘˜fÔ%Ø×"Ñ" 6Õ*ûà×$Ñ$ WÕ-ús#    .B= ÁB Á "B= Â$B:Â:B= Â=Cc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r#   rI   zCallable[_P, object]rm   z_P.argsrn   z	_P.kwargsr&   ÚNoner'   )r(   s   "r   r)   r*   @  s,   € ÷ 6ñ 6Ø%ð6Ø.5ð6ØAJð6à	ñ6r!   c                ó,   <€ \         SV `  ! V.VO5/ VB # )a:  
Extend the base cleanup feature with support for cleanup functions which
return Deferreds.

If the function C{f} returns a Deferred, C{TestCase} will wait until the
Deferred has fired before proceeding to the next function.

If the function takes more than C{timeout} settings, then the test will
raise an error.
)r   Ú
addCleanup)r   rI   rm   rn   r   s   &&*,€r   rÇ   ÚTestCase.addCleanup@  s   ø€ ô ‰wÒ! !Ð5 dÒ5¨fÑ5Ð5r!   c                	ó"   € V P                  4       # rS   )rd   )r   s   &r   ÚgetSuppressÚTestCase.getSuppressO  s   € Ø× Ñ Ó"Ð"r!   c                ó   € \         P                  ! V P                  R\         P                  4      p \	        V4      #   \
        \        3 d0    \        P                  ! R\        R7       \         P                  u # i ; i)a5  
Returns the timeout value set on this test. Checks on the instance
first, then the class, then the module, then packages. As soon as it
finds something with a C{timeout} attribute, returns that. Returns
L{util.DEFAULT_TIMEOUT_DURATION} if it cannot find anything. See
L{TestCase} docstring for more details.
rM   z)'timeout' attribute needs to be a number.rP   )
r   ÚacquireAttributeÚ_parentsÚDEFAULT_TIMEOUT_DURATIONÚfloatÚ
ValueErrorr`   rª   r«   r]   )r   rM   s   & r   rZ   ÚTestCase.getTimeoutR  sj   € ô ×'Ò'Ø�M‰M˜9¤d×&CÑ&Có
ˆð
	1Ü˜“>Ð!øÜœIÐ&ô 	1ô
 �MŠMØ;ÔFXõô ×0Ñ0Ò0ð	1ús   ²
= ½=A=Á<A=c                óª  aa€ V'       d   \        R4      h^ RIHo . oV3R lpVV3R lp\        P                  ! V\
        P                  ! R\        R7      4      pV3R lp\        P                  ! V\
        P                  ! R\        R7      4      pVP                  R4        VP                  V4       S'       d    RoVP                  4        R# VP                  V4       VSn         SP                  4        S=S'       g   V P                  '       d    RoVP                  4        R# \        4       h  S=i ; i  RoTP                  4        i ; i)	zATake a Deferred that only ever callbacks. Block until it happens.z_wait is not reentrantr   c                ó6   <€ Se   SP                  V 4       R # R # rS   )r”   )ÚanyÚresultss   &€r   r”   ÚTestCase._wait.<locals>.appendr  s   ø€ ØÒ"Ø—‘˜sÖ#ñ #r!   c                ó4   <€ Se   SP                  4        R # R # rS   ©rA   )Úignr   rÖ   s   &€€r   rA   ÚTestCase._wait.<locals>.crashv  s   ø€ ØÒ"Ø—‘–ñ #r!   zreactor\.crash cannot be used.*)ÚmessagerQ   c                 ó(   <€ S P                  4        R # rS   rÙ   r   s   €r   r}   ÚTestCase._wait.<locals>.stop�  s   ø€ Ø�M‰MŽOr!   N)ÚRuntimeErrorr   r   r   r[   r   r\   r]   r”   rf   r‘   r}   rl   rB   r|   )r   rG   Úrunningr”   rA   r}   r   rÖ   s   &&&   @@r   rÁ   ÚTestCase._waiti  s  ù€ çÜÐ7Ó8Ð8å,àˆõ	$ö	 ô ×&Ò&ØÜ�MŠMØ:ÔEWôó
ˆõ	ô ×%Ò%ØÜ�MŠMØ:ÔEWôó
ˆð 	�‰�tÔð$	Ø�I‰I�fÔßð ð< ˆGØ�K‰KŽMð= �I‰I�eÔØˆGŒLð!Ø—‘”à�L÷ ˜$Ÿ.Ÿ.˜.Øð" ˆGØ�K‰KŽMô $Ó%Ð%øð- ‘Lûð0 ˆGØ�K‰K�Mús6   Â%D> ÃD> Ã,D7 Ã<	D> ÄD> Ä-
D> Ä7D;Ä;D> Ä>E)r‚   r¬   rB   r   r   )ÚrunTest)r’   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r9   ÚfailUnlessFailureri   ro   rv   rr   rƒ   rt   r   ÚinlineCallbacksrs   r¡   r¥   r²   r·   r¼   rÂ   rÇ   rÊ   rZ   r   rÁ   Ú__static_attributes__Ú__classcell__)r   s   @r   r   r   !   s—   ø† ñ÷2õ0/ð2 &Ðò&òP)ò2òò>%ò 	!ð ×Ññ!ó ð!ò*$ò 5òò$Bò	"ò.÷.6ð 6ò#ò1ð.  0÷ Gò Gr!   r   )Ú__conditional_annotations__ræ   Ú
__future__r   r^   rª   Útypingr   r   Úzope.interfacer   r   r   r   r   Útwisted.internet.deferr	   Útwisted.pythonr
   Útwisted.trialr   r   Útwisted.trial._synctestr   r   r   r   r   Ú__annotations__Ú	ITestCaser   )rë   s   @r   Ú<module>rõ      sq   øðô
õ #ã Û ß !å &å ÷
 *Ý %Ý "ß &ß KÑ Káˆtƒ_€à!Ð �*Ó !ñ ˆV×ÑÓôNÐ"ó Nó òNr!   