
    F\h                     J    S SK r S SKrS SKrS SKrSSKJr  Sr " S S\5      rg)    N   )TestCaseTc                      ^  \ rS rSrSrSU 4S jjrS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rSU 4S jjrU 4S jrS rSrU =r$ )IsolatedAsyncioTestCase
   Nc                 f   > [         TU ]  U5        S U l        [        R                  " 5       U l        g N)super__init___asyncioRunnercontextvarscopy_context_asyncioTestContext)self
methodName	__class__s     */usr/lib/python3.13/unittest/async_case.pyr    IsolatedAsyncioTestCase.__init__'   s)    $"#.#;#;#=     c                    #    g 7fr	    r   s    r   
asyncSetUp"IsolatedAsyncioTestCase.asyncSetUp,           c                    #    g 7fr	   r   r   s    r   asyncTearDown%IsolatedAsyncioTestCase.asyncTearDown/   r   r   c                0    U R                   " U/UQ70 UD6  g r	   )
addCleanupr   funcargskwargss       r   addAsyncCleanup'IsolatedAsyncioTestCase.addAsyncCleanup2   s     	$1&1r   c                   #    [        U5      n UR                  nUR                  nU" U5      I Sh  vN nU R                  XASSS5        U$ ! [         a(    [	        SUR
                   SUR                   S35      Sef = f NO7f)zEnters the supplied asynchronous context manager.

If successful, also adds its __aexit__ method as a cleanup
function and returns the result of the __aenter__ method.
'.zC' object does not support the asynchronous context manager protocolN)type
__aenter__	__aexit__AttributeError	TypeError
__module____qualname__r&   )r   cmclsenterexitresults         r   enterAsyncContext)IsolatedAsyncioTestCase.enterAsyncContextA   s      2h	'NNE==D
 RyTtT48  	'a/q1A1A0B CT U "&'	' !s%   BA BBB2A??Bc                     U R                   R                  5         U R                  R                  U R                  5        U R                  U R                  5        g r	   )r   get_loopr   runsetUp
_callAsyncr   r   s    r   
_callSetUp"IsolatedAsyncioTestCase._callSetUpU   s>     	$$&  $$TZZ0(r   c                 f    U R                  U5      b  [        R                  " SU S3[        SS9  g g )NzFIt is deprecated to return a value that is not None from a test case ()   )
stacklevel)_callMaybeAsyncwarningswarnDeprecationWarning)r   methods     r   _callTestMethod'IsolatedAsyncioTestCase._callTestMethod]   s<    '3MM ((.xq23ERSU 4r   c                     U R                  U R                  5        U R                  R                  U R                  5        g r	   )r=   r   r   r;   tearDownr   s    r   _callTearDown%IsolatedAsyncioTestCase._callTearDownb   s,    **+  $$T]]3r   c                 0    U R                   " U/UQ70 UD6  g r	   )rD   )r   functionr$   r%   s       r   _callCleanup$IsolatedAsyncioTestCase._callCleanupf   s    X777r   c                    U R                   c   S5       e[        R                  " U5      (       d   U< S35       eU R                   R                  U" U0 UD6U R                  S9$ )N!asyncio runner is not initializedz is not an async functioncontextr   inspectiscoroutinefunctionr;   r   r"   s       r   r=   "IsolatedAsyncioTestCase._callAsynci   sr    "".S0SS.**400VTH<U2VV0""&&$!&!,, ' 
 	
r   c                    U R                   c   S5       e[        R                  " U5      (       a*  U R                   R                  U" U0 UD6U R                  S9$ U R                  R                  " U/UQ70 UD6$ )NrT   rU   rW   r"   s       r   rD   'IsolatedAsyncioTestCase._callMaybeAsyncq   s    "".S0SS.&&t,,&&**d%f%00 +  
 ++//FtFvFFr   c                 v    U R                   b   S5       e[        R                  " SU R                  S9nXl         g )Nz%asyncio runner is already initializedT)debugloop_factory)r   asyncioRunnerr_   r   runners     r   _setupAsyncioRunner+IsolatedAsyncioTestCase._setupAsyncioRunner{   s6    ""*S,SS*d9J9JK$r   c                 <    U R                   nUR                  5         g r	   )r   closerb   s     r   _tearDownAsyncioRunner.IsolatedAsyncioTestCase._tearDownAsyncioRunner   s    $$r   c                    > U R                  5          [        TU ]	  U5      U R                  5         $ ! U R                  5         f = fr	   )rd   r
   r;   rh   )r   r6   r   s     r   r;   IsolatedAsyncioTestCase.run   s9      "	*7;v&'')D'')s	   2 Ac                 b   > U R                  5         [        TU ]	  5         U R                  5         g r	   )rd   r
   r^   rh   )r   r   s    r   r^   IsolatedAsyncioTestCase.debug   s$      "##%r   c                 @    U R                   b  U R                  5         g g r	   )r   rh   r   s    r   __del__IsolatedAsyncioTestCase.__del__   s    *'') +r   )r   r   )runTestr	   )__name__r0   r1   __firstlineno__r_   r   r   r   r&   r7   r>   rI   rM   rQ   r=   rD   rd   rh   r;   r^   ro   __static_attributes____classcell__)r   s   @r   r   r   
   sa    6 L>
2()U
48
G%
*&
* *r   r   )r`   r   rX   rE   caser   
__unittestr   r   r   r   <module>rx      s'        
H*h H*r   