ó
    ×›‘hn<  ã                  óø   • % S r SSKJr  SSKrSSKrSSKJrJr  SSKJ	r	  SSK
Jr  SSKJrJr  SSKJr  SS	KJr  SS
KJrJr  SSKJrJrJr  \" S5      r/ rS\S'   \	" \R:                  5       " S S\5      5       rg)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                  óî   ^ • \ rS rSrSrSU 4S jjr      SS jr\rS rS r	S r
S rS	 rS
 r\R                  S 5       rS rS rS rS rS rS r        SU 4S jjrS rS r\4S jrSrU =r$ )ÚTestCaseé!   a  
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                óJ   >• [         TU ]  U5        SSKJn  X l        SU l        g)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.
r   ©ÚreactorFN)ÚsuperÚ__init__Útwisted.internetr   Ú_twistedPrivateSchedulerÚ_twistedPrivateNeedsTearDown)ÚselfÚ
methodNamer   Ú	__class__s      €Ú\C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/trial/_asynctest.pyr   ÚTestCase.__init__1   s)   ø€ ô 	‰Ñ˜Ô$õ 	-ð )0Ô%ð -2ˆÕ)ó    c                óB   ^ ^• U 4S jnUU 4S jnUR                  X45      $ )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                ó.   >• TR                  SU < 35      e)Nz$did not catch an error, instead got )ÚfailureException)Úignorer   s    €r!   Ú_cbÚ#TestCase.assertFailure.<locals>._cbR   s    ø€ Ø×'Ñ'Ø6°v±jÐAóð r#   c                óœ   >• U R                   " T6 (       a  U R                  $ SR                  T[        U 5      5      nTR	                  U5      e)Nz
Expected: {!r}
Got:
{})ÚcheckÚvalueÚformatÚstrr&   )r   ÚoutputÚexpectedFailuresr   s     €€r!   Ú_ebÚ#TestCase.assertFailure.<locals>._ebW   sF   ø€ Ø�}Š}Ð.Ö/Ø—}‘}Ð$à5×<Ñ<Ø$¤c¨'£ló�ð ×+Ñ+¨FÓ3Ð3r#   )ÚaddCallbacks)r   Údeferredr0   r(   r1   s   ` `  r!   ÚassertFailureÚTestCase.assertFailureI   s    ù€ õ	ö
	4ð ×$Ñ$ SÓ.Ð.r#   c                óü  ^ ^^^^• T R                  5       mUUU U4S jn[        R                  " U[        R                  " [
        S95      n[        R                  " U5      (       a0  [        SR                  U5      5      n[        R                  " U5      $ [        R                  " [        R                  T R                  5       U5      nT R                  R!                  TXF5      mUR#                  U4S j5        U$ )Nc                óª  >• [         R                  " T< ST ST S35      n[        R                  " U5      n U R	                  U5        g ! [         R
                   as    TR                  R                  5         STl        TR                  5       nUb*  UR                  U5      (       a  TR                  TX#5         g TR                  TU5         g f = f)Nz (z) still running at z secsT)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 ÁA0CÂ=CÃC©Úcategoryz9{!r} is a generator function and therefore will never runc                ód   >• TR                  5       =(       a    TR                  5       =(       d    U $ ©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   ÚfuncrG   rH   rJ   ÚexcrC   rS   rI   s	   ` ``   @@r!   Ú_runÚTestCase._rund   sÈ   ü€ Ø—/‘/Ó#ˆ÷	-ð 	-ô, ×*Ò*Ø”t—}’}Ô.@ÑAó
ˆ	ô ×&Ò& t×,Ñ,ÜØK×RÑRÐSWÓXóˆCô —:’:˜c“?Ð"Ü×ÒÜ×+Ñ+¨T×->Ñ->Ó-@À$ó
ˆð ×,Ñ,×6Ñ6°wÀ	ÓMˆØ	�	‰	Ô@ÔAØˆr#   c                ó&   • U R                   " U0 UD6$ rO   )Úrun)r   ÚargsÚkwargss      r!   Ú__call__ÚTestCase.__call__Œ   s   € Ø�xŠx˜Ð( Ñ(Ð(r#   c              ƒ  óx  #   •   U R                  U5      I S h  v•N   U R                  U5      I S h  v•N    U R                  (       a  U R                  U5      I S h  v•N   g g  NJ N3! U R                  U5      I S h  v•N    f = f N)! U R                  (       a  U R                  U5      I S h  v•N    f f = f7frO   )Ú_deferSetUpAndRunÚ_deferRunCleanupsr   Ú_deferTearDown©r   rH   s     r!   Ú_deferSetUpÚTestCase._deferSetUp�   s    é € ð	2ð5Ø×,Ñ,¨VÓ4×4Ð4à×,Ñ,¨VÓ4×4Ñ4à×0×0Ø×)Ñ)¨&Ó1×1Ñ1ð 1ñ	 5á4ø�d×,Ñ,¨VÓ4×4Ò4úñ 2øð ×0×0Ø×)Ñ)¨&Ó1×1Ò1ð 1üsv   ‚B:…A( ™A$šA( žB	 ²A&³B	 ¸%B:ÁBÁB:Á$A( Á&B	 Á(BÁ=B Á>BÂB	 ÂB:Â	&B7Â/B2Â0B7Â7B:c              ƒ  óH  #   •  U R                  U R                  SU5      I Sh  v•N   SU l         U R                  [        X R                  5      U R                  U5      I Sh  v•N   U R                  5       b   UR                  X R                  5       5        gSU l        g N}! [         a5  nUR                  X R	                  U R                  U5      5         SnAgSnAf[
         a@  nUR                  U [        R                  " U5      5        UR                  5          SnAgSnAf[         a0  nUR                  U [        R                  " U5      5         SnAgSnAff = f GN! [         a,  nU R#                  [        R                  " U5      U5        e SnAff = f7f)zS
Execute the setUp and run part of a test. Teardown and cleanups are not executed.
ÚsetUpNT)re   ru   r   ÚaddSkipÚ_getSkipReasonÚKeyboardInterruptrB   r   r:   ÚstopÚBaseExceptionr   ÚgetattrÚ_testMethodNamer?   ÚaddUnexpectedSuccessÚ_passedÚ_ebDeferTestMethod©r   rH   rD   s      r!   rn   Ú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"±3E) Á$E&Á%4E) ÂF"ÂE) Â!F"Â"B$ Â$
E#Â.+CÃF"ÃE#Ã+6D&Ä!F"Ä&E#Ä3&EÅF"ÅE#Å#F"Å&E) Å)
FÅ3'FÆFÆF"c           	     ó6  • U R                  5       nUb)  UR                  U5      (       a  UR                  XU5        g UR                  U R                  [
        5      (       a  UR                  X5        g UR                  [        5      (       a"  UR                  X5        UR                  5         g UR                  [        5      (       a?  UR                  X R                  [        X R                  5      UR                  5      5        g UR                  X5        g rO   )r?   r@   rA   r+   r&   r   Ú
addFailurerx   rB   ry   r   rv   rw   r{   r|   r,   )r   rE   rH   rF   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              ƒ  ó‚  #   •  U R                  U R                  SU5      I S h  v•N   g  N! [         aG  nUR                  U [        R
                  " U5      5        UR                  5         SU l         S nAg S nAf[         a7  nUR                  U [        R
                  " U5      5        SU l         S nAg S nAff = f7f)NÚtearDownF)	re   r†   rx   rB   r   r:   ry   r~   rz   r€   s      r!   rp   Ú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ûð	!üsH   ‚B?„ , ¤*¥, ©B?ª, ¬
B<¶=A8Á3B?Á8B<Â-B7Â2B?Â7B<Â<B?c              #  ó¶  ^^^#   • / n[        U R                  5      S:”  ab  U R                  R                  5       u  mmm U R                  UUU4S jSTR                   3U5      v •  [        U R                  5      S:”  a  Mb  U H  nUR                  X5        SU l
        M     g! [
         a'    UR                  [        R                  " 5       5         Nmf = f7f)zN
Run any scheduled cleanups and report errors (if any) to the result.
object.
r   c                 ó   >• T" T 0 TD6$ rO   © )ri   rc   rj   s   €€€r!   rT   Ú,TestCase._deferRunCleanups.<locals>.<lambda>Þ   s   ø€ ™D $Ð1¨&Ò1r#   zcleanup function FN)ÚlenÚ	_cleanupsÚpopre   Ú__name__Ú	ExceptionÚappendr   r:   rB   r~   )r   rH   ÚfailuresrE   ri   rc   rj   s       @@@r!   ro   ÚTestCase._deferRunCleanupsÓ   s¶   úé € ð ˆÜ�$—.‘.Ó! AÓ%Ø!%§¡×!3Ñ!3Ó!5ÑˆD�$˜ð3Ø—i‘iÞ1Ø'¨¯© Ð7Øóò ô �$—.‘.Ó! AÕ%ó ˆAØ�O‰O˜DÔ$Ø ˆDŽLò øô ó 3Ø—‘¤§¢Ó 1Ö2ð3üs/   …:CÁ (B% Á(CÂ"CÂ%.CÃCÃCÃCc                óÚ  •  [         R                  " X5      R                  5       nU(       d  SU l        U R                  R                  5        H  nUR                  X5        SU l        M     U R                  5         U R                  5         U R                  (       a  UR                  U 5        g g ! [         a/    UR                  U [        R                  " 5       5        SU l         Nµf = f)NF)r   Ú_JanitorÚpostCaseCleanupr~   rz   rB   r   r:   Ú	_observerÚ	getErrorsÚflushLoggedErrorsÚ_removeObserverÚ
addSuccess)r   rH   Ú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   ‚2B1 Â16C*Ã)C*c                ó¸   •  [         R                  " X5      R                  5         g ! [         a(    UR	                  U [
        R                  " 5       5         g f = frO   )r   r•   ÚpostClassCleanuprz   rB   r   r:   rq   s     r!   Ú_classCleanUpÚTestCase._classCleanUpù   s@   € ð	5Ü�MŠM˜$Ó'×8Ñ8Õ:øÜó 	5Ø�O‰O˜D¤'§/¢/Ó"3Ö4ð	5ús   ‚$' §/AÁAc                ó   ^ ^• UU 4S jnU$ )z}
Create a method which wraps the reactor method C{name}. The new
method issues a deprecation warning and calls the original.
c                 ót   >• [         R                  " ST< ST< S3S[        S9  TR                  T   " U 0 UD6$ )Nz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.é   )Ú
stacklevelrM   )ÚwarningsÚwarnrY   Ú_reactorMethods)ÚaÚkwÚnamer   s     €€r!   Ú_Ú&TestCase._makeReactorMethod.<locals>._  s@   ø€ Ü�M‹Mó 26³tð=ð Ü+òð ×'Ñ'¨Ò-¨qÐ7°BÑ7Ð7r#   rŠ   )r   r­   r®   s   `` r!   Ú_makeReactorMethodÚTestCase._makeReactorMethodÿ   s   ù€ ö	8ð ˆr#   c                óŠ   • 0 U l         S H6  n[        X5      U R                   U'   [        XU R                  U5      5        M8     g)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.
)r=   Úiteratery   N)rª   r{   Úsetattrr°   )r   r   r­   s      r!   Ú_deprecateReactorÚTestCase._deprecateReactor  s@   € ð  "ˆÔÛ0ˆDÜ)0°Ó)?ˆD× Ñ  Ñ&Ü�G 4×#:Ñ#:¸4Ó#@ÖAò 1r#   c                óp   • U R                   R                  5        H  u  p#[        XU5        M     0 U l         g)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                ó¤  • SSK Jn  U R                  U5        SU l         [        R
                  R                  U R                  U5      5      n U R                  U5        U R                  U5        U R                  U5         U R                  U5        g! U R                  U5        U R                  U5        f = f! U R                  U5        f = f)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   r   FN)r   r   rµ   r>   r   ÚDeferredÚfromCoroutinerr   Ú_waitrž   r¢   rº   )r   rH   r   rC   s       r!   Ú_runFixturesAndTestÚTestCase._runFixturesAndTest)  s¥   € õ 	-à×Ñ˜wÔ'ØˆŒð	.Ü—‘×,Ñ,¨T×-=Ñ-=¸fÓ-EÓFˆAð+Ø—
‘
˜1”à—‘˜fÔ%Ø×"Ñ" 6Õ*à×$Ñ$ WÕ-øð —‘˜fÔ%Ø×"Ñ" 6Õ*ûà×$Ñ$ WÕ-ús#    .B< ÁB Á "B< Â$B9Â9B< Â<Cc                ó,   >• [         TU ]  " U/UQ70 UD6$ )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   rE   ri   rj   r    s       €r!   rÃ   ÚTestCase.addCleanup@  s   ø€ ô ‰wÒ! !Ð5 dÒ5¨fÑ5Ð5r#   c                ó"   • U R                  5       $ rO   )r`   )r   s    r!   ÚgetSuppressÚTestCase.getSuppressO  s   € Ø× Ñ Ó"Ð"r#   c                óø   • [         R                  " U R                  S[         R                  5      n [	        U5      $ ! [
        [        4 a,    [        R                  " S[        S9  [         R                  s $ f = f)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.
rI   z)'timeout' attribute needs to be a number.rL   )
r   ÚacquireAttributeÚ_parentsÚDEFAULT_TIMEOUT_DURATIONÚfloatÚ
ValueErrorr\   r¨   r©   rY   )r   rI   s     r!   rV   ÚTestCase.getTimeoutR  sj   € ô ×'Ò'Ø�M‰M˜9¤d×&CÑ&Có
ˆð
	1Ü˜“>Ð!øÜœIÐ&ó 	1ô
 �MŠMØ;ÔFXòô ×0Ñ0Ò0ð	1ús   ²
= ½9A9Á8A9c                ó’  ^^• U(       a  [        S5      eSSKJm  / mU4S jnUU4S jn[        R                  " U[
        R                  " S[        S95      nU4S jn[        R                  " U[
        R                  " S[        S95      nUR                  S	5         UR                  U5        T(       a   S	mUR                  5         g	UR                  U5        UTl         TR                  5         T?T(       d  U R                  (       a   S	mUR                  5         g	[        5       e! T?f = f! S	mUR                  5         f = f)
zATake a Deferred that only ever callbacks. Block until it happens.z_wait is not reentrantr   r   c                ó0   >• Tb  TR                  U 5        g g rO   )r‘   )ÚanyÚresultss    €r!   r‘   ÚTestCase._wait.<locals>.appendr  s   ø€ ØÑ"Ø—‘˜sÕ#ð #r#   c                ó.   >• Tb  TR                  5         g g rO   ©r=   )Úignr   rÒ   s    €€r!   r=   ÚTestCase._wait.<locals>.crashv  s   ø€ ØÑ"Ø—‘•ð #r#   zreactor\.crash cannot be used.*)ÚmessagerM   c                 ó&   >• T R                  5         g rO   rÕ   r   s   €r!   ry   ÚTestCase._wait.<locals>.stop�  s   ø€ Ø�M‰M�Or#   N)ÚRuntimeErrorr   r   r	   rW   r   rX   rY   r‘   rb   rŽ   ry   rh   r>   rx   )r   rC   Úrunningr‘   r=   ry   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ús0   ÂD2 Ã
D2 Ã#D+ Ã3D2 Ä!
D2 Ä+D/Ä/D2 Ä2E)r~   rª   r>   r   r   )ÚrunTest)r4   údefer.Deferred[_T]r0   ztype[BaseException]Úreturnrß   )rE   zCallable[_P, object]ri   z_P.argsrj   z	_P.kwargsrà   ÚNone)r�   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r5   ÚfailUnlessFailurere   rk   rr   rn   r   rp   r   ÚinlineCallbacksro   rž   r¢   r°   rµ   rº   rÀ   rÃ   rÆ   rV   r   r¿   Ú__static_attributes__Ú__classcell__)r    s   @r!   r   r   !   sÊ   ø† ñ÷2ð0/Ø*ð/Ø?Rð/à	ô/ð2 &Ðò&òP)ò2òò>%ò 	!ð ×Ññ!ó ð!ò*$ò 5òò$Bò	"ò.ð.6Ø%ð6Ø.5ð6ØAJð6à	÷6ò#ò1ð.  0÷ Gò Gr#   r   )rå   Ú
__future__r   rZ   r¨   Útypingr   r   Úzope.interfacer   Útyping_extensionsr   r   r   r	   Útwisted.internet.deferr
   Útwisted.pythonr   Útwisted.trialr   r   Útwisted.trial._synctestr   r   r   r   r   Ú__annotations__Ú	ITestCaser   rŠ   r#   r!   Ú<module>rô      sp   ðò
õ #ã Û ß !å &å '÷
 *Ý %Ý "ß &ß KÑ Káˆtƒ_€à!Ð �*Ó !ñ ˆV×ÑÓôNÐ"ó Nó ñNr#   