
    RhY                     F    d dl Z d dlZd dlZd dlZddlmZ  G d de      Zy)    N   )TestCasec                        e Zd Zd fd	Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd fd	Z fdZd Z xZS )IsolatedAsyncioTestCasec                 d    t         |   |       d | _        t        j                         | _        y N)super__init___asyncioRunnercontextvarscopy_context_asyncioTestContext)self
methodName	__class__s     */usr/lib/python3.12/unittest/async_case.pyr
   z IsolatedAsyncioTestCase.__init__#   s)    $"#.#;#;#=     c                    K   y wr    r   s    r   
asyncSetUpz"IsolatedAsyncioTestCase.asyncSetUp(   	        c                    K   y wr   r   r   s    r   asyncTearDownz%IsolatedAsyncioTestCase.asyncTearDown+   r   r   c                0     | j                   |g|i | y r   )
addCleanupr   funcargskwargss       r   addAsyncCleanupz'IsolatedAsyncioTestCase.addAsyncCleanup.   s     	$1&1r   c                   K   t        |      }	 |j                  }|j                  } ||       d{   }| j                  ||ddd       |S # t        $ r( t	        d|j
                   d|j                   d      dw xY w7 Ow)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   enterAsyncContextz)IsolatedAsyncioTestCase.enterAsyncContext=   s      2h	'NNE==D
 RyT2tT48  	'a/q1A1A0B CT U "&'	' !s%   BA BBB1A??Bc                     | j                   j                          | j                  j                  | j                         | j                  | j                         y r   )r   get_loopr   runsetUp
_callAsyncr   r   s    r   
_callSetUpz"IsolatedAsyncioTestCase._callSetUpQ   s>     	$$&  $$TZZ0(r   c                 h    | j                  |      !t        j                  d| dt        d       y y )NzFIt is deprecated to return a value that is not None from a test case ()   )
stacklevel)_callMaybeAsyncwarningswarnDeprecationWarning)r   methods     r   _callTestMethodz'IsolatedAsyncioTestCase._callTestMethodY   s<    '3MM ((.xq23ERSU 4r   c                     | j                  | j                         | j                  j                  | j                         y r   )r7   r   r   r5   tearDownr   s    r   _callTearDownz%IsolatedAsyncioTestCase._callTearDown^   s,    **+  $$T]]3r   c                 0     | j                   |g|i | y r   )r=   )r   functionr    r!   s       r   _callCleanupz$IsolatedAsyncioTestCase._callCleanupb   s    X777r   c                    | j                   J d       t        j                  |      s
J |d       | j                   j                   ||i || j                        S )N!asyncio runner is not initializedz is not an async functioncontextr   inspectiscoroutinefunctionr5   r   r   s       r   r7   z"IsolatedAsyncioTestCase._callAsynce   so    "".S0SS.**40VTH<U2VV0""&&$!&!,, ' 
 	
r   c                    | j                   J d       t        j                  |      r-| j                   j                   ||i || j                        S  | j                  j                  |g|i |S )NrJ   rK   rM   r   s       r   r=   z'IsolatedAsyncioTestCase._callMaybeAsyncm   s    "".S0SS.&&t,&&**d%f%00 +  
 04++//FtFvFFr   c                 d    | j                   J d       t        j                  d      }|| _         y )Nz%asyncio runner is already initializedT)debug)r   asyncioRunnerr   runners     r   _setupAsyncioRunnerz+IsolatedAsyncioTestCase._setupAsyncioRunnerw   s0    ""*S,SS*d+$r   c                 <    | j                   }|j                          y r   )r   closerU   s     r   _tearDownAsyncioRunnerz.IsolatedAsyncioTestCase._tearDownAsyncioRunner|   s    $$r   c                     | j                          	 t        | 	  |      | j                          S # | j                          w xY wr   )rW   r	   r5   rZ   )r   r1   r   s     r   r5   zIsolatedAsyncioTestCase.run   s9      "	*7;v&'')D'')s	   2 Ac                 b    | j                          t        | 	          | j                          y r   )rW   r	   rR   rZ   )r   r   s    r   rR   zIsolatedAsyncioTestCase.debug   s$      "##%r   c                 >    | j                   | j                          y y r   )r   rZ   r   s    r   __del__zIsolatedAsyncioTestCase.__del__   s    *'') +r   )runTestr   )__name__r+   r,   r
   r   r   r"   r2   r8   rB   rE   rH   r7   r=   rW   rZ   r5   rR   r^   __classcell__)r   s   @r   r   r   	   sU    4>
2()U
48
G%
*&
*r   r   )rS   r   rN   r>   caser   r   r   r   r   <module>rc      s"        E*h E*r   