
    w8'h
                         d dl Z e j                  dd dk  r3d dlZd dlZd dlmZ d dlmZmZm	Z	 d dl
mZ d Zd Zd	 Z G d
 de      Zyd dlmZ d dl
mZ y)    N   )      )_is_coroutine)ismethod
isfunctionCO_COROUTINE)TestCasec                     t        | t        j                        r'| j                  } t        | t        j                        r'| S N)
isinstance	functoolspartialfunc)r   s    J/var/www/html/trade_iq/venv/lib/python3.12/site-packages/mock/backports.py_unwrap_partialr      s2    y00199D y001    c                     t        |       r| j                  } t        |       rt        |       } t        |       syt	        | j
                  j                  |z        S )zReturn true if ``f`` is a function (or a method or functools.partial
        wrapper wrapping a function) whose code object has the given ``flag``
        set in its flags.F)r   __func__r   r   bool__code__co_flags)fflags     r   _has_code_flagr      sK     qk

A qkA!}AJJ''$.//r   c                 L    t        | t              xs t        | dd      t        u S )z}Return true if the object is a coroutine function.

        Coroutine functions are defined with "async def" syntax.
        r   N)r   r	   getattrr   )objs    r   iscoroutinefunctionr      s*     3- AC$/=@	
r   c                   >     e Zd Zd fd	Zd Zd Zd Zd fd	Z xZS )IsolatedAsyncioTestCasec                 @    t         |   |       d | _        d | _        y r   )super__init___asyncioTestLoop_asyncioCallsQueue)self
methodName	__class__s     r   r$   z IsolatedAsyncioTestCase.__init__(   s     GZ($(D!&*D#r   c                    K   t        j                         x| _        }|j                  d        	 |j	                          d {   }|j                          |J -7 wr   )asyncioQueuer&   
set_resultget	task_done)r'   futqueuequerys       r   _asyncioLoopRunnerz*IsolatedAsyncioTestCase._asyncioLoopRunner-   sR     .5mmo=D#eNN4 #iik)!}$} )s   AAAAc                 .   | j                   J t        j                         }t        j                  |       |j	                  d       || _         |j                         }|j                  | j                  |            | _        |j                  |       y )NT)
r%   r+   new_event_loopset_event_loop	set_debugcreate_futurecreate_taskr3   _asyncioCallsTaskrun_until_complete)r'   loopr0   s      r   _setupAsyncioLoopz)IsolatedAsyncioTestCase._setupAsyncioLoop5   s~    ((000))+D""4(NN4 $(D!$$&C%)%5%5d6M6Mc6R%SD"##C(r   c                    | j                   J | j                   }d | _         | j                  j                  d        |j                  | j                  j	                                	 |j                  |j                                t        j                  d        |j                          y # t        j                  d        |j                          w xY wr   )	r%   r&   
put_nowaitr;   joinshutdown_asyncgensr+   r6   close)r'   r<   s     r   _tearDownAsyncioLoopz,IsolatedAsyncioTestCase._tearDownAsyncioLoop?   s    ((444((D$(D!##..t4##D$;$;$@$@$BC''(?(?(AB&&t,

 &&t,

s   'B, ,'Cc                     | j                          	 t        | 	  |      | j                          S # | j                          w xY wr   )r=   r#   runrC   )r'   resultr)   s     r   rE   zIsolatedAsyncioTestCase.runM   s9    ""$,w{6*))+))+s	   2 A)runTestr   )	__name__
__module____qualname__r$   r3   r=   rC   rE   __classcell__)r)   s   @r   r!   r!   &   s!    	+
	%	)		, 	,r   r!   )r   )r!   )sysversion_infor+   r   asyncio.coroutinesr   inspectr   r   r	   unittestr
   r   r   r   r!    r   r   <module>rR      sR    
 BQ& 0::!
	0
,,( ,,b ,0r   