
    z%iY                     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     G/home/uftp/.pyenv/versions/3.12.0/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)N'.zC' object does not support the asynchronous context manager protocol)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1B  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                   ||i || j                        S N)context)r   r5   r   r   s       r   r7   z"IsolatedAsyncioTestCase._callAsynce   s8     ""&&$!&!,, ' 
 	
r   c                    t        j                  |      r-| j                  j                   ||i || j                        S  | j                  j                  |g|i |S rJ   )inspectiscoroutinefunctionr   r5   r   r   s       r   r=   z'IsolatedAsyncioTestCase._callMaybeAsyncm   si    &&t,&&**d%f%00 +  
 04++//FtFvFFr   c                 >    t        j                  d      }|| _        y )NT)debug)asyncioRunnerr   r   runners     r   _setupAsyncioRunnerz+IsolatedAsyncioTestCase._setupAsyncioRunnerw   s    d+$r   c                 <    | j                   }|j                          y r   )r   closerS   s     r   _tearDownAsyncioRunnerz.IsolatedAsyncioTestCase._tearDownAsyncioRunner|   s    $$r   c                     | j                          	 t        | 	  |      | j                          S # | j                          w xY wr   )rU   r	   r5   rX   )r   r1   r   s     r   r5   zIsolatedAsyncioTestCase.run   s9      "	*7;v&'')D'')s	   2 Ac                 b    | j                          t        | 	          | j                          y r   )rU   r	   rP   rX   )r   r   s    r   rP   zIsolatedAsyncioTestCase.debug   s$      "##%r   c                 >    | j                   | j                          y y r   )r   rX   r   s    r   __del__zIsolatedAsyncioTestCase.__del__   s    *'') +r   )runTestr   )__name__r+   r,   r
   r   r   r"   r2   r8   rB   rE   rH   r7   r=   rU   rX   r5   rP   r\   __classcell__)r   s   @r   r   r   	   sU    4>
2()U
48
G%
*&
*r   r   )rQ   r   rM   r>   caser   r   r   r   r   <module>ra      s"        E*h E*r   