
    Ah                     (   d dl Z e j                  dd dkD  rd dlmZ n6e j                  dd dk\  rd dlmZ nd dlZd dlmZ d dlmZm	Z	m
Z
 d Zd	 Zd
 Z	 d dlmZ 	 d dlmZ y# e$ r d dlZd dlmZ  G d de      ZY $w xY w# e$ r	 d dlmZ Y yw xY w)    N   )   	   )iscoroutinefunction)r      )_is_coroutine)ismethod
isfunctionCO_COROUTINEc                     t        | t        j                        r'| j                  } t        | t        j                        r'| S N)
isinstance	functoolspartialfunc)r   s    Y/var/www/html/Telegram-Engagement-Pod-/env/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   r   r      s*     3- AC$/=@	
r   )IsolatedAsyncioTestCase)TestCasec                   >     e Zd Zd fd	Zd Zd Zd Zd fd	Z xZS )r    c                 @    t         |   |       d | _        d | _        y r   )super__init___asyncioTestLoop_asyncioCallsQueue)self
methodName	__class__s     r   r%   z IsolatedAsyncioTestCase.__init__2   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._asyncioLoopRunner7   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_taskr4   _asyncioCallsTaskrun_until_complete)r(   loopr1   s      r   _setupAsyncioLoopz)IsolatedAsyncioTestCase._setupAsyncioLoop?   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,   r7   close)r(   r=   s     r   _tearDownAsyncioLoopz,IsolatedAsyncioTestCase._tearDownAsyncioLoopI   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$   runrD   )r(   resultr*   s     r   rF   zIsolatedAsyncioTestCase.runW   s9    ""$,w{6*))+))+s	   2 A)runTestr   )	__name__
__module____qualname__r%   r4   r>   rD   rF   __classcell__)r*   s   @r   r    r    0   s!    	+
	%	)		, 	,r   r    )_set_event_loop_policy)set_event_loop_policy)sysversion_infoinspectr   r,   r   asyncio.coroutinesr   r	   r
   r   r   r   unittestr    ImportErrorr!   rM   rN    r   r   <module>rV      s    
 BQ& +bqV#+ 0::
	0
3,0j.Gk  1,!,,( ,,1,l  .-.s$   A# B #B ?B BB