
    BThA              	      $   U d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZmZ ddlmZmZmZmZmZmZmZmZ ddlmZ ddlmZmZmZmZmZm Z  ddl!Z!ddl"Z"ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 e
jh                  d	k\  rdd
lm5Z5 ndd
l6m5Z5 ed   Z7 ed      Z8 edeee   ee   f         Z9 e5d      Z:ee:e9f   Z; G d de<      Z= G d de=      Z> G d de?ej                        ZAdZBdldZCe ddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dmd       ZDe 	 dnddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dod       ZD	 	 dp	 	 	 	 	 	 	 dqdZDdrdZEdsdZFdrdZGdtd ZHd!ZIdud"ZJ e"j                  d#$      dvd%       ZL	 	 	 	 	 	 dwd'ZMdxd(ZN	 	 	 	 	 	 	 	 	 	 dyd)ZOdzd*ZPdxd+ZQdxd,ZR	 	 	 	 	 	 d{d-ZS	 	 	 	 	 	 	 	 d|d.ZT	 	 	 	 d}d/ZU G d0 d1e(      ZV G d2 d3eV      Z G d4 d5eV      ZW G d6 d7eV      ZX G d8 d9eV      ZY eZ       Z[d&e\d:<    e"j                  d;d#<      	 	 	 	 	 	 	 	 d~d=       Z] e"j                  d;d#>      	 	 	 	 	 	 	 	 dd?       Z^ e3e?          Z_e#d@e-dAe,dBe2dCiZ`dDe\dE<   g ZadFe\dG<   e"j                  ddH       Zbej                  ddI       Zd edJ      Ze e"j                  d#$      ddK       Zf e"j                  d#L      	 	 	 	 ddM       ZgddNZhddOZiddPZj edQ      ZkddRZlddSZmddTZn	 d	 	 	 ddUZo e"j                  d#d#V      ddW       Zp	 	 ddXZq edY      ZrddZZsd[Ztd\Zu	 	 	 	 	 	 dd]Zvdd^Zwdd_Zxe"j                  dd`       Zyej                  dda       Zz e"j                  dCb      	 	 	 	 	 	 ddc       Z{ e"j                  dCd#d      dde       Z|ddfZ}ddgZ~e"j                  ddh       Ze"j                  ddi       Z e"j                  dCb      ddj       Z e"j                  dCb      ddk       Zy)zpytest-asyncio implementation.    )annotationsN)AbstractEventLoopAbstractEventLoopPolicy)AsyncIterator	Awaitable	Coroutine	GeneratorIterableIteratorMappingSequence)dedent)AnyCallableLiteralTypeVarUnionoverload)Class	CollectorConfig
FixtureDefFixtureRequestFunctionItemMarkMetafuncModulePackageParserPytestCollectionWarningPytestDeprecationWarningPytestPluginManagerSessionStashKey)   
   )	ParamSpec)sessionpackagemoduleclassfunction_T_R)bound_Pc                      e Zd ZdZy)PytestAsyncioErrorz2Base class for exceptions raised by pytest-asyncioN__name__
__module____qualname____doc__     g/var/www/catia.catastroantioquia-mas.com/valormas/lib/python3.12/site-packages/pytest_asyncio/plugin.pyr3   r3   F   s    <r:   r3   c                      e Zd ZdZy) MultipleEventLoopsRequestedErrorz9Raised when a test requests multiple asyncio event loops.Nr4   r9   r:   r;   r=   r=   J   s    Cr:   r=   c                      e Zd ZdZdZy)ModeautostrictN)r5   r6   r7   AUTOSTRICTr9   r:   r;   r?   r?   N   s    DFr:   r?   z'auto' - for automatically handling all async functions by the plugin
'strict' - for autoprocessing disabling (useful if different async frameworks should be tested together, e.g. both pytest-asyncio and pytest-trio are used in the same project)
c                    | j                  d      }|j                  ddd dt               | j                  ddd       | j                  d	d
dd        | j                  dd
dd       y )Nasyncioz--asyncio-modeasyncio_modeMODE)destdefaultmetavarhelpz default value for --asyncio-moderA   )rK   rI   "asyncio_default_fixture_loop_scopestringzFdefault scope of the asyncio event loop used to execute async fixtures)typerK   rI   asyncio_default_test_loop_scopez=default scope of the asyncio event loop used to execute testsr-   )getgroup	addoptionASYNCIO_MODE_HELPaddini)parserpluginmanagergroups      r;   pytest_addoptionrW   [   s    OOI&E	OO   MM/  
 MM,U	   MM)L	  r:   .)scope
loop_scopeparamsautouseidsnamec                    y Nr9   fixture_functionrX   rY   rZ   r[   r\   r]   s          r;   fixturerb   w   s     "r:   c                    y r_   r9   r`   s          r;   rb   rb      s	     DGr:   c                    | "t        |        t        j                  | fi S t        j                  t              dfd       }|S )Nc                     t        | fdiS )NrY   )rb   )ra   kwargsrY   s    r;   innerzfixture.<locals>.inner   s    +M
MfMMr:   )ra   FixtureFunction[_P, _R]returnrh   )_make_asyncio_fixture_functionpytestrb   	functoolswraps)ra   rY   rf   rg   s    `` r;   rb   rb      sQ     #&'7D~~.9&99 
	!	N 
"	N r:   c                6    t        | d|       } t        | dd      S )N__func___force_asyncio_fixtureFgetattrobjs    r;   _is_asyncio_fixture_functionru      s     
#z3
'C30%88r:   c                P    t        | d      r| j                  } d| _        || _        y )Nro   T)hasattrro   rp   _loop_scope)rt   rY   s     r;   rj   rj      s$    sJll!%C COr:   c                Z    t        j                  |       xs t        j                  |       S r_   )inspectiscoroutinefunctionisasyncgenfunctionrs   s    r;   _is_coroutine_or_asyncgenr}      s#    &&s+Nw/I/I#/NNr:   c                    | j                  d      }|| j                  d      }	 t        |      S # t        $ r=}dj	                  d t        D              }t        j                  |d| d      |d }~ww xY w)NrF   , c              3  4   K   | ]  }|j                     y wr_   )value).0ms     r;   	<genexpr>z$_get_asyncio_mode.<locals>.<genexpr>   s     0a!''0s   z+ is not a valid asyncio_mode. Valid modes: .)	getoptiongetinir?   
ValueErrorjoinrk   
UsageError)configvalemodess       r;   _get_asyncio_moder      s    


>
*C
{mmN+Cy 		0400g@qI
	s   
1 	A78A22A7a  The configuration option "asyncio_default_fixture_loop_scope" is unset.
The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"
c                    | j                  d      }|s"t        j                  t        t                     | j                  dd       y )NrL   markerszQasyncio: mark the test as a coroutine, it will be run using an asyncio event loop)r   warningswarnr"   !_DEFAULT_FIXTURE_LOOP_SCOPE_UNSETaddinivalue_line)r   default_loop_scopes     r;   pytest_configurer      s>    'KL./PQR
	*r:   T)tryfirstc                    t        |       }| j                  d      }t        |       }d| d| d| g}ddj                  |      z   gS )z$Add asyncio config to pytest header.rL   zmode=z#asyncio_default_fixture_loop_scope=z asyncio_default_test_loop_scope=z	asyncio: r   )r   r   _get_default_test_loop_scoper   )r   modedefault_fixture_loop_scopedefault_test_loop_scopeheaders        r;   pytest_report_headerr      sn     V$D!'/S!T:6B
v
-.H-IJ
*+B*CDF 	dii'' r:   set[FixtureDef]c                J   | j                   }|j                  d      }t        |      }|j                  j	                  d      }|J |j
                  j                         D ]>  }|D ]5  }|j                  }||v st        |      s |t        j                  k(  rt        |      s?t        |dd       xs |xs |j                  }	|	dk(  r#d|j                  vr|xj                  dz  c_        t        ||	       t!        j"                  |      }
d|
j$                  v r+t'        j(                  t+        |j,                   d             d|j                  vr|xj                  d	z  c_        t/        |       t        |j                        sJ |j1                  |       8 A y )
NrL   
funcmanagerx   r-   
event_loop)r    is asynchronous and explicitly requests the "event_loop" fixture. Asynchronous fixtures and test functions should use "asyncio.get_running_loop()" instead.request)r   )r   r   r   rU   
get_plugin_arg2fixturedefsvaluesfuncr}   r?   rC   ru   rr   rX   argnamesrj   rz   	signature
parametersr   r   r"   r5   _synchronize_async_fixtureadd)	collectorprocessed_fixturedefsr   r   rF   fixturemanagerfixtures
fixturedefr   rX   function_signatures              r;   _preprocess_async_fixturesr      s    F'KL$V,L))44\BN%%%"33::< !2"  	2J??D22:S; t{{*3OPT3U mT2 $%$## 
 
"|:;N;N'N##6#*47!(!2!24!81<<<,==/ *# $ 
 3 33##|3#&z2/
@@@!%%j1A 	2!2r:   c                    t        j                  | j                        rt        |        yt        j                  | j                        rt        |        yy)zIWraps the fixture function of an async fixture in a synchronous function.N)rz   r|   r   _wrap_asyncgen_fixturer{   _wrap_async_fixture)r   s    r;   r   r     s;    !!*//2z*		$	$Z__	5J' 
6r:   c                    t        j                  |       }|j                         }d|j                  v r||d<   d|j                  v r||d<   |S )Nr   r   )rz   r   copyr   )r   rf   r   r   sigrets         r;   _add_kwargsr   '  sO     

D
!C
++-CCNN" Is~~%&LJr:   c                    |E| d }}	 | j                   t        | j                        }}|t	        ||      r|j                  |      } | S # t        $ r Y ,w xY wr_   )ro   rN   __self__AttributeError
isinstance__get__)r   instanceunboundclss       r;   _perhaps_rebind_fixture_funcr   6  se     T	==$t}}*=SG
 ?z(C8??8,DK  		s   !A
 
	AAc                h    | j                   t        j                        dfd       }|| _         y )Nc           
       	
 t        | j                        }t        | |      }| j                  |      	|j	                  |d         |di t        ||	|       

fd}t        j                         t        	 |             }	j                  |      }t              d	
fd}| j                  |       |S )Nc                 D   K   j                          d {   } | S 7 wr_   )	__anext__)resgen_objs    r;   setupzH_wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.setupS  s"     ))++CJ ,s     c                 l    dfd} t         |              }j                  |                yy)zYield again, to finalize.c                    K   	 j                          d {    d} | dz  } t        |       7 # t        $ r Y y w xY ww)Nz$Async generator fixture didn't stop.zYield only once.)r   r   StopAsyncIteration)msgr   s    r;   async_finalizerze_wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.finalizer.<locals>.async_finalizer`  sQ     *!++--- AC--C$S/) .) s,   A 1 /1 A 1 	=A =A Nri   None)_create_task_in_contextrun_until_complete)r   taskcontextr   r   reset_contextvarss     r;   	finalizerzL_wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.finalizer]  s:    * +:7H'RD))$/ ,!# -r:   r9   r   )r   r   ,_get_event_loop_fixture_id_for_async_fixturegetfixturevaluepopr   contextvarscopy_contextr   r   _apply_contextvar_changesaddfinalizer)r   rf   r   event_loop_fixture_idr   
setup_taskresultr   r   r   r   r   rb   s           @@@@r;   _asyncgen_fixture_wrapperz9_wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapperI  s    +GW5E5EF LT!
 ,,-BC


($/HT6:wGH	 **,,Z'J
..z:5g>	$ 	$$ 	Y'r:   r   r   rf   r   r   rl   rm   )r   r   rb   s     @r;   r   r   F  s1    ooG__W& &P 0JOr:   c                h    | j                   t        j                        dfd       }|| _         y )Nc                T   	 t        
 j                        	t         	      } j                  |      j	                  |d        	 fd}t        j                         }t         |       |      }j                  |      }t        |      }| j                  |       |S )Nc            
     L   K    di t               d {   } | S 7 w)Nr9   )r   )r   r   r   rf   r   s    r;   r   zB_wrap_async_fixture.<locals>._async_fixture_wrapper.<locals>.setup  s-     N{4WMNNCJ Os   $"$)r   r   r   r   r   r   r   r   r   r   r   )r   rf   r   r   r   r   r   r   r   r   rb   s   ``      @@r;   _async_fixture_wrapperz3_wrap_async_fixture.<locals>._async_fixture_wrapperx  s    +GW5E5EF LT!
 ,,-BC


($/	 **,,Z'J
..z: 6g>(  !23r:   r   r   )r   r   rb   s     @r;   r   r   u  s0    ooG__W < -JOr:   c                    | j                   j                  d      }t        |dd       xs |xs | j                  }|dk(  rd}n6t	        | j
                  |      }|j                  j                  t        d      }|sJ |S )NrL   rx   r-   r    )	r   r   rr   rX   _retrieve_scope_root_pyfuncitemstashget_event_loop_fixture_id)r   r   r   rY   r   event_loop_nodes         r;   r   r     s     !../STmT*Q.@QGMM  Z ,.w/B/BJO / 5 5 9 9"!

 !    r:   c                j    	 | j                  ||      S # t        $ r | j                  |      cY S w xY w)a   
    Return an asyncio task that runs the coro in the specified context,
    if possible.

    This allows fixture setup and teardown to be run as separate asyncio tasks,
    while still being able to use context-manager idioms to maintain context
    variables and make those variables visible to test functions.

    This is only fully supported on Python 3.11 and newer, as it requires
    the API added for https://github.com/python/cpython/issues/91150.
    On earlier versions, the returned task will use the default context instead.
    )r   )create_task	TypeError)loopcoror   s      r;   r   r     s=    "&g66 &%%&s    22c                    g | D ]Y  }	 |j                         | j                  |      u r&	 |j                  | j                  |            }j                  ||f       [ syfd}|S # t        $ r Y Jw xY w)z
    Copy contextvar changes from the given context to the current context.

    If any contextvars were modified by the fixture, return a finalizer that
    will restore them.
    Nc                 Z    r(j                         \  } }| j                  |       r'y y r_   )r   reset)vartokencontext_tokenss     r;   restore_contextvarsz6_apply_contextvar_changes.<locals>.restore_contextvars  s)    )--/LS%IIe r:   )r   LookupErrorsetappend)r   r   r   r   r   s       @r;   r   r     s     N 	,	wwyGKK,, - C()sEl+	, 
   		s   !A,,	A87A8c                  F    e Zd ZdZedd       Zedd       Zedd       Zy)	PytestAsyncioFunctionz<Base class for all test functions managed by pytest-asyncio.c               X    | j                         D ]  }|j                  |      s|c S  y)z
        Returns a subclass of PytestAsyncioFunction if there is a specialized subclass
        for the specified function item.

        Return None if no specialized subclass exists for the specified item.
        N)__subclasses___can_substitute)r   itemsubclasss      r;   item_subclass_forz'PytestAsyncioFunction.item_subclass_for  s4     **, 	 H''-	  r:   c          	        |j                  d      sJ | j                  |j                  |j                  t	        |dd      |j
                  |j                  |j                  |j                        }|j                  |_	        |j                  |j                  k(  sJ t        j                  |j
                        }d|j                  v r'|j                  t        |j                   d             |S )zq
        Instantiates this specific PytestAsyncioFunction type from the specified
        Function item.
        rE   callspecN)r]   r  callobjfixtureinfokeywordsoriginalnamer   r   )get_closest_markerfrom_parentparentr]   rr   rt   _fixtureinfor  r  own_markersrz   r   r   r   r"   )r   r-   subclass_instancesubclassed_function_signatures       r;   _from_functionz$PytestAsyncioFunction._from_function  s     **9555OOOOXz48LL --&&!.. , 
 )1(<(<% ,,0D0DDDD(/(9(9:K:O:O(P%8CCC""((--. /V W ! r:   c                    t               )zDReturns whether the specified function can be replaced by this class)NotImplementedErrorr  s    r;   r  z%PytestAsyncioFunction._can_substitute  s     "##r:   N)r  r   ri   z"type[PytestAsyncioFunction] | Noner-   r   ri   r   r  r   ri   bool)	r5   r6   r7   r8   classmethodr
  r  staticmethodr  r9   r:   r;   r  r    s?    F
 
 ! !8 $ $r:   r  c                  6     e Zd ZdZedd       Zd fdZ xZS )r   z"Pytest item created by a coroutinec                D    | j                   }t        j                  |      S r_   )rt   rz   r{   r  r   s     r;   r  zCoroutine._can_substitute  s    xx**400r:   c                V    t        | j                        | _        t        |           y r_   wrap_in_syncrt   superruntestself	__class__s    r;   r(  zCoroutine.runtest   "    HH
 	r:   r  r   r5   r6   r7   r8   r   r  r(  __classcell__r+  s   @r;   r   r     s"    ,1 1 r:   r   c                  @     e Zd ZdZedd       Zed fd       Z xZS )AsyncGeneratorz0Pytest item created by an asynchronous generatorc                D    | j                   }t        j                  |      S r_   )rt   rz   r|   r#  s     r;   r  zAsyncGenerator._can_substitute+  s    xx))$//r:   c                   t         |   |      }d|j                   d}|j                  t	        |             |j                  t        j                  j                  d|             |S )Nz:Tests based on asynchronous generators are not supported. z will be ignored.F)runreason)	r'  r  r]   r   r!   
add_markerrk   markxfail)r   r-   async_gen_itemunsupported_item_type_messager+  s       r;   r  zAsyncGenerator._from_function0  sp    /9H}}o.0 	& 	34QRS!!KK%0MN	
 r:   r  r  )	r5   r6   r7   r8   r   r  r  r  r.  r/  s   @r;   r1  r1  (  s,    :0 0 
 
r:   r1  c                  6     e Zd ZdZedd       Zd fdZ xZS )AsyncStaticMethodzf
    Pytest item that is a coroutine or an asynchronous generator
    decorated with staticmethod
    c                h    | j                   }t        |t              xr t        |j                        S r_   )rt   r   r   r}   ro   r#  s     r;   r  z!AsyncStaticMethod._can_substituteD  s.    xx$- 
2KMM3
 	
r:   c                V    t        | j                        | _        t        |           y r_   r%  r)  s    r;   r(  zAsyncStaticMethod.runtestK  r,  r:   r  r   r-  r/  s   @r;   r<  r<  >  s&    
 
 
 r:   r<  c                  6     e Zd ZdZedd       Zd fdZ xZS )AsyncHypothesisTestzh
    Pytest item that is coroutine or an asynchronous generator decorated by
    @hypothesis.given.
    c                    | j                   }t        |dd      xr8 t        |dd       xr) t        j                  |j                  j
                        S )Nis_hypothesis_testF
hypothesis)rt   rr   rz   r{   rC  
inner_testr#  s     r;   r  z#AsyncHypothesisTest._can_substituteY  sM    xxD.6 HlD1H++DOO,F,FG	
r:   c                    t        | j                  j                  j                        | j                  j                  _        t        |           y r_   )r&  rt   rC  rD  r'  r(  r)  s    r;   r(  zAsyncHypothesisTest.runtestb  s9    )5HH***
& 	r:   r  r   r-  r/  s   @r;   r@  r@  S  s&    
 
 
 r:   r@  _HOLDERpytest_pycollect_makeitem)specnamer   c                H    | j                  |      syt        | t               y)z,A pytest hook to collect asyncio coroutines.N)funcnamefilterr   rF  )r   r]   rt   s      r;   3pytest_pycollect_makeitem_preprocess_async_fixturesrK  n  s"    
 ##D)y'2r:   )rH  hookwrapperc              #  V  K   d}	 |j                         }|syt        |t              rt        |      }nt        |f      }g }|D ]  }|}	t        |t              rt        j                  |      }
|
rjt        |j                        t        j                  k(  r"|j                  d      s|j                  d       |j                  d      r|
j                  |      }	|j!                  |	        |j#                  |       y# t        $ r}|j                  |       Y d}~yd}~ww xY ww)zl
    Converts coroutines and async generators collected as pytest.Functions
    to AsyncFunction items.
    NrE   )
get_resultBaseExceptionforce_exceptionr   r   iterr   r  r
  r   r   r?   rB   r  r6  r  r  force_result)r   r]   rt   hook_resultnode_or_list_of_nodesr   node_iteratorupdated_node_collectionnodeupdated_itemspecialized_item_classs              r;   =pytest_pycollect_makeitem_convert_async_functions_to_subclassrZ  {  s     K ""$ 	 !'223 356  5dH%%:%L%LT%R"%$KKYY'+'>'>y'IOOI.**95#9#H#H#NL&&|45 45/  ##A&s.   D)D C*D)	D&D!D)!D&&D)r,   r*   r+   r)   z+Mapping[type[pytest.Collector], _ScopeName] _fixture_scope_by_collector_typezlist[Callable[..., Any]]__package_loop_stackc                :    	 t         fdt        j                         D              }|dk(  r$t        j
                  }| j                  t        <   y  j                   d}| j                  t        <   t        j                  ||      	 	 dd       t               t        u rt        j                         y t         t               r fd} j"                   _        | _        y t         t&              r j(                  _        y y # t        $ r Y y w xY w)Nc              3  @   K   | ]  \  }}t        |      r|  y wr_   )r   )r   r   rX   r   s      r;   r   z&pytest_collectstart.<locals>.<genexpr>  s'      
U)S) 
s   r)   z::<event_loop>)rX   r]   c              7     K   | }t        |      5  t               5 }t        j                  |       | d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY wwr_   _temporary_event_loop_policy_provide_event_looprE   set_event_loop)event_loop_policyargsnew_loop_policyr   s       r;   scoped_event_loopz.pytest_collectstart.<locals>.scoped_event_loop  sZ      ,(9	!	%)""4(J	 	 	 	 	 	1   AAAA	AA	AAAc                     j                   } | 3| _        	 t        j                         }|| _        j                         S j                         S # t
        $ r Y j                         S w xY wr_   )rt   "__pytest_asyncio_scoped_event_loopr\  r   *__pytest_asyncio_package_scoped_event_loop
IndexError__original_collect)r+   package_loopr   rg  s     r;   _patched_collectz-pytest_collectstart.<locals>._patched_collect  sw    ]]F!<M9#7#;#;#=LHTFE //119//11 " //11s   A 	A.-A.ri   #Iterator[asyncio.AbstractEventLoop])nextr[  itemsStopIteration_session_event_loopr5   r   r   nodeidrk   rb   rN   r   r\  r  r   r   collectrm  r   rt   rj  )r   collector_scoper   ro  rg  s   `   @r;   pytest_collectstartry    s    
>DDF
 
 )# 3 < <2G	./  )//0?.CIOO*+^^"
 
-
	
  I'!
 	##$56	Iv	&
	2 (1'8'8	$,		Iu	%;L	8 
&K  s   &D 	DDc              #  r  K   t        j                         }	 t               }t        j                  |        	 d  	 t               }|A|j                         s1t        j                  t        |z  t               |j                          t        j                  |       	 t               j                          t        j                  |       y # t        $ r d }Y w xY w# t        $ r d }Y w xY w# t        $ r Y Cw xY w# 	 t               }n# t        $ r d }Y nw xY w|A|j                         s1t        j                  t        |z  t               |j                          t        j                  |       	 t               j                          n# t        $ r Y nw xY wt        j                  |       w xY wwr_   )rE   get_event_loop_policy_get_event_loop_no_warnRuntimeErrorset_event_loop_policy	is_closedr   r   _UNCLOSED_EVENT_LOOP_WARNINGDeprecationWarningcloserc  )policyold_loop_policyold_loopcurrent_loops       r;   ra  ra    s    335O*, !!&))	 5L5NL #L,B,B,DMM,|;"  %%o6	#%++- 	x(;    	 L	 "  		'	 5L5NL 	 L	 #L,B,B,DMM,|;"  %%o6	#%++- 		x(s   F7
C F7C? 
C AF7 C0 8F7CF7CF7C-*F7,C--F70	C<9F7;C<<F7?F4
DF4DF4DAF46FF4	FF4FF44F7a      The event_loop fixture provided by pytest-asyncio has been redefined in
    %s:%d
    Replacing the event_loop fixture with a custom implementation is deprecated
    and will lead to errors in the future.
    If you want to request an asyncio event loop with a scope other than function
    scope, use the "loop_scope" argument to the asyncio mark when marking the tests.
    If you want to return different types of event loops, use the event_loop_policy
    fixture.
    c                x   | j                   j                  d      }|sy t        | j                        }t	        ||      }|dk(  ry t        | j                   |      }|j                  j                  t        d       }|r|| j                  v ry | j                  j                  j                  d      }|J d| j                  v r?t        t        j                  | j                   j                  ||j                              | j                  j!                  |       |j"                  |   | j"                  |<   y y )NrE   r-   r   r   )	test_namerX   scoped_loop_node)
definitionr  r   r   _get_marked_loop_scoper   r   r   r   fixturenamesrU   r   r=   _MULTIPLE_LOOPS_REQUESTED_ERRORformatrv  r  r   )metafuncmarkerr   rX   r   r   r   s          r;   pytest_generate_testsr  5  s2     33I>F5hooF"6+=>E
*8+>+>FO+11556LdS
 !H$9$99!66AA,O)))80002/66&1188%4%;%; 7   	$$%:;++,AB 	!!"78- r:   )rL  c              #  \  K   | j                   dk(  rt        | t        t        t	        j
                               t               d}|j                         }t        j                  | j                        }t        |      sEt        j                  | j                        \  }}t        j                  t        ||fz  t                t	        j
                         }	 t#        |      }||urt        |      s|j%                          |j)                  |       yd y# t&        $ r Y "w xY ww)z<Adjust the event loop policy when an event loop is produced.r   N)argname_add_finalizers_close_event_loop_restore_event_loop_policyrE   r{  _provide_clean_event_looprN  rz   getsourcefiler   _is_pytest_asyncio_loopgetsourcelinesr   r   %_REDEFINED_EVENT_LOOP_FIXTURE_WARNINGr  r|  r  r}  rc  )r   outcomer   fixture_filename_fixture_line_numberr  r  s           r;   pytest_fixture_setupr  \  s    
 \) 	&w'D'D'FG%		
 *1*<*<*> #00A&t,%,%;%;JOO%L"A"MM5#%89:"
 ..0	.v6Ht#,CH,M  	d#	  	 		s*   CD,*D D,	D)&D,(D))D,c                    d| _         | S )NT)__pytest_asyncior   s    r;   _make_pytest_asyncio_loopr    s     DKr:   c                    t        | dd      S )Nr  Frq   r  s    r;   r  r    s    4+U33r:   c                F    t        |      D ]  }| j                  |        y)a  
    Registers the specified fixture finalizers in the fixture.

    Finalizers need to be specified in the exact order in which they should be invoked.

    :param fixturedef: Fixture definition which finalizers should be added to
    :param finalizers: Finalizers to be added
    N)reversedr   )r   
finalizersr   s      r;   r  r    s&     j) +		*+r:   a      pytest-asyncio detected an unclosed event loop when tearing down the event_loop
    fixture: %r
    pytest-asyncio will close the event loop for you, but future versions of the
    library will no longer do so. In order to ensure compatibility with future
    versions, please make sure that:
        1. Any custom "event_loop" fixture properly closes the loop after yielding it
        2. The scopes of your custom "event_loop" fixtures do not overlap
        3. Your code does not modify the event loop in async fixtures or tests
    c                    t        j                         } 	 | j                         }|Nt	        |      sB|j                         s!t        j                  t        |z  t               |j                          y y y # t        $ r d }Y ^w xY wr_   )rE   r{  get_event_loopr}  r  r  r   r   r  r  r  )r  r   s     r;   r  r    s}    **,F$$&  7 =~~MM,t3" 	

 !>  s   A7 7BBc                      fd}|S )Nc                     	 t              } | rt        |       s| j                          t	        j
                         y # t        $ r d } Y @w xY wr_   )r|  r}  r  r  rE   r~  )r   previous_policys    r;   _restore_policyz3_restore_event_loop_policy.<locals>._restore_policy  sL    	*?;D /5JJL%%o6	  	D	s   A AAr9   )r  r  s   ` r;   r  r    s    	7 r:   c                     t        j                         } 	 t        |       }|.t	        |      s"| j                         }| j                  |       y y y # t        $ r d }Y >w xY wr_   )rE   r{  r|  r}  r  new_event_looprc  )r  r  new_loops      r;   r  r    sl     **,F*62 $;H$E((*h' %F  s   A A A c                    t        j                         5  t        j                  dt               | | j	                         cd d d        S t        j                         cd d d        S # 1 sw Y   y xY w)Nignore)r   catch_warningssimplefilterr  r  rE   )r  s    r;   r|  r|    s`     
	 	 	" ,h(:;((*, ,
 ))+, , ,s   ,A(A((A1)r   rL  c           
   #    K   | j                  d      t        | t              rt        | j                        }| j
                  j                  j                         D ]q  \  }}|d   j                  }|t        j                  k(  s)t        |      s5t        |      rAt        j                  t        d| j                   d|d      d       s n(| j                  t#        j$                  d	|  d
             d yw)z
    Pytest hook called before a test case is run.

    Wraps marked tests in a synchronous function
    where the wrapped test coroutine is executed in an event loop.
    rE   Nzasyncio test z! requested async @pytest.fixture z in strict mode. You might want to use @pytest_asyncio.fixture or switch to auto mode. This will become an error in future versions of flake8-asyncio.   )
stacklevelz	The test z is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove the asyncio mark. If the test is not marked explicitly, check for global marks applied via 'pytestmark'.)r  r   r  r   r   r  name2fixturedefsrs  r   r?   rC   r}   ru   r   r   r"   r]   rk   PytestWarning)
pyfuncitemrF   fixnamer   r   s        r;   pytest_pyfunc_callr    s      $$Y/;j"78,Z->->?L%/%<%<%M%M%S%S%U !  |(( DKK/1$78>MM0+JOO+> ?/&k *.. $%4 OO$$
| ,G G 
s   BC?C?C?A!C?c                r     t         dd      }|| t        j                          fd       } |_        |S )zd
    Return a sync wrapper around an async function executing it in the
    current event loop.
    _raw_test_funcNc                      | i |}t               }t        j                  ||      }	 |j                  |       y # t        $ r2 |j                         r |j                         s|j                           w xY w)Nr  )r|  rE   ensure_futurer   rO  done	cancelled	exception)re  rf   r   _loopr   r   s        r;   rg   zwrap_in_sync.<locals>.inner'  so    T$V$')$$T6	$$T* 	 yy{4>>#3 	s	   > ;A9)rr   rl   rm   r  )r   raw_funcrg   s   `  r;   r&  r&    sI     t-t4H__T   ELr:   a          Multiple asyncio event loops with different scopes have been requested
        by {test_name}. The test explicitly requests the event_loop fixture, while
        another event loop with {scope} scope is provided by {scoped_loop_node}.
        Remove "event_loop" from the requested fixture in your test to run the test
        in a {scope}-scoped event loop or remove the scope argument from the "asyncio"
        mark to run the test in a function-scoped event loop.
    c                   | j                  d      }|y t        | j                        }t        ||      }|dk7  r t	        | |      }|j
                  t           }nd}| j                  }||vr|j                  |       t        | dd       }t        |dd      s(t        |dd      rt        j                  d| d	       y y y )
NrE   r-   r   rt   rC  FrB  ztest function `zU` is using Hypothesis, but pytest-asyncio only works with Hypothesis 3.64.0 or later.)r  r   r   r  r   r   r   r  r  rr   rk   fail)r  r  r   rX   parent_noder   r  rt   s           r;   pytest_runtest_setupr  F  s    $$Y/F~5dkkB"6+=>E
*47 + 1 12H I ,$$LL012
$t
$C3e,!52 	dX &: :	
2,r:   zeAn asyncio pytest marker defines both "scope" and "loop_scope", but it should only use "loop_scope".
zvThe "scope" keyword argument to the asyncio marker has been deprecated. Please use the "loop_scope" argument instead.
c                   | j                   dk(  sJ | j                  s&| j                  r%t        | j                        ddhz
  rt	        d      d| j                  v rId| j                  v rt        j                  t              t        j                  t        t                     | j                  j                  d      xs | j                  j                  d      }||}|dv sJ |S )NrE   rY   rX   z:mark.asyncio accepts only a keyword argument 'loop_scope'.>   r,   r+   r*   r)   r-   )r]   re  rf   r  r   rk   r   &_DUPLICATE_LOOP_SCOPE_DEFINITION_ERRORr   r   r"   '_MARKER_SCOPE_KWARG_DEPRECATION_WARNINGr   )asyncio_markerr   rX   s      r;   r  r  i  s     )+++#n&;&;"<g?V"VUVV.'''>000##$JKK./VWX!!%%l3 ~7L7L7P7P8E }"IIIILr:   c                $    | j                  d      S )NrO   )r   )r   s    r;   r   r   ~  s    ==:;;r:   c                "   t         t        t        t        d}||   }t	        | j                               D ].  }t        ||      st        |t        j                        sJ |c S  | j                   d| d| d}t        j                  |      )N)r,   r+   r*   r)   z1 is marked to be run in an event loop with scope z, but is not part of any r   )r   r   r   r$   r  	listchainr   rk   r   r]   r   )r  rX   node_type_by_scopescope_root_typerW  error_messages         r;   r   r     s    	 )/O)* dO,dF$4$4555K
 99+Fug N""'	+  

M
**r:   c              #     K   | j                  t        j                        }t        |      5  t	               5 }| ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY ww)z@Create an instance of the default event loop for each test case.N)r   rd  r5   ra  rb  )r   rf  r   s      r;   r   r     s^      --.?.H.HIO	%o	6 8K8M QU
     s2   +A&AAA	A&A	AA#A&c               #    K   t        j                         j                         } t        |       } 	 |  | j	                         s1	 | j                  | j                                | j                          y y # t        $ r'}t        j                  d| t               Y d }~=d }~ww xY w# | j                          w xY w# | j	                         sz	 | j                  | j                                n3# t        $ r'}t        j                  d| t               Y d }~nd }~ww xY w| j                          w # | j                          w xY ww xY ww)Nz Error cleaning up asyncio loop: )rE   r{  r  r  r  r   shutdown_asyncgens	Exceptionr   r   RuntimeWarningr  )r   r   s     r;   rb  rb    s    ((*99;D %T*D

 ~~''(?(?(AB 

    V @DnUUV 

 ~~''(?(?(AB V @DnUUV 



  s   .EB? EA7 %E7	B' B"B* "B''B* *B<<E?EC10D51	D!:DD5D!!D5$E5EEE)rX   c              #     K   |}t        |      5  t               5 }t        j                  |       | d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY wwr_   r`  )r   rd  rf  r   s       r;   ru  ru    sZ      (O	%o	6 8K8M QUt$
     rh  )rX   r[   c                 *    t        j                         S )zDReturn an instance of the policy used to create asyncio event loops.)rE   r{  r9   r:   r;   rd  rd    s     ((**r:   c                "    t        | t              S )z4Returns whether a test item is a pytest-asyncio test)r   r  r  s    r;   is_async_testr    s    d122r:   c                    t        j                  t        j                  |             5 }|j                  d       |j	                         d   cddd       S # 1 sw Y   yxY w)z<Find an unused localhost port from 1024-65535 and return it.)rN   )z	127.0.0.1r   r  N)
contextlibclosingsocketbindgetsockname)socket_typesocks     r;   _unused_portr    sN    			FMM{;	< %		"#!!$% % %s   $AA!c                 4    t        t        j                        S r_   )r  r  SOCK_STREAMr9   r:   r;   unused_tcp_portr    s    **++r:   c                 4    t        t        j                        S r_   )r  r  
SOCK_DGRAMr9   r:   r;   unused_udp_portr    s    ))**r:   c                 &    t               fd} | S )z9A factory function, producing different unused TCP ports.c                     t        t        j                        } | v rt        t        j                        } | v rj                  |        | S zReturn an unused port.)r  r  r  r   portproduceds    r;   factoryz(unused_tcp_port_factory.<locals>.factory  sH    F../h 2 23D h 	Tr:   r  r  r  s    @r;   unused_tcp_port_factoryr         uH	 Nr:   c                 &    t               fd} | S )z9A factory function, producing different unused UDP ports.c                     t        t        j                        } | v rt        t        j                        } | v rj                  |        | S r  )r  r  r  r   r  s    r;   r  z(unused_udp_port_factory.<locals>.factory  sH    F--.h 1 12D h 	Tr:   r  r  s    @r;   unused_udp_port_factoryr    r  r:   )rT   r    rU   r#   ri   r   )ra   rh   rX   0_ScopeName | Callable[[str, Config], _ScopeName]rY   _ScopeName | NonerZ   Iterable[object] | Noner[   r  r\   QIterable[str | float | int | bool | None] | Callable[[Any], object | None] | Noner]   
str | Noneri   rh   ).)ra   r   rX   r  rY   r  rZ   r  r[   r  r\   r  r]   r   ri   z<Callable[[FixtureFunction[_P, _R]], FixtureFunction[_P, _R]])NN)ra   zFixtureFunction[_P, _R] | NonerY   r  rf   r   ri   zVFixtureFunction[_P, _R] | Callable[[FixtureFunction[_P, _R]], FixtureFunction[_P, _R]])rt   r   ri   r  )rt   r   rY   r  ri   r   )r   r   ri   r?   )r   r   ri   r   )r   r   ri   z	list[str])r   r   r   r   ri   r   )r   r   ri   r   )
r   zCallable[..., Any]rf   dict[str, Any]r   asyncio.AbstractEventLoopr   r   ri   r  )r   r.   r   z
Any | Noneri   r.   )r   r   r   r   ri   str)r   r  r   zAbstractCoroutine[Any, Any, _T]r   contextvars.Contextri   zasyncio.Task[_T])r   r  ri   zCallable[[], None] | None)r   pytest.Module | pytest.Classr]   r  rt   objectri   zLpytest.Item | pytest.Collector | list[pytest.Item | pytest.Collector] | None)r   r  r]   r  rt   r  ri   $Generator[None, pluggy.Result, None])r   zpytest.Collectorri   r   )r  r   ri   zIterator[None])r  r   ri   r   )r   r   ri   r  )r   r   ri   r   )r   r   ri   r  )r   r   r  zCallable[[], object]ri   r   r   )ri   zCallable[[], None]r_   )r  zAbstractEventLoopPolicy | Noneri   r  )r  r   ri   zobject | None)r   zCallable[..., Awaitable[Any]])r  zpytest.Itemri   r   )r  r   r   
_ScopeNameri   r  )r   r   ri   r  )r  zCollector | ItemrX   r  ri   r   )r   r   ri   rq  rp  )r   r   rd  r   ri   rq  )ri   r   )r  r   ri   r  )r  intri   r	  )ri   r	  )ri   zCallable[[], int])r8   
__future__r   rE   r  r   enumrl   rz   r  sysr   r   r   collections.abcr   r   r   AbstractCoroutiner	   r
   r   r   r   textwrapr   typingr   r   r   r   r   r   pluggyrk   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   version_infor(   typing_extensionsr  r.   r/   r1   FixtureFunctionr  r3   r=   r  Enumr?   rR   rW   rb   ru   rj   r}   r   r   r   hookimplr   r   r   r   r   r   r   r   r   r   r  r1  r<  r@  r  rF  __annotations__rK  rZ  r   r[  r\  ry  contextmanagerra  r  r  r  r  r  r  r  r  r  r  r|  r  r&  r  r  r  r  r  r   r   r   rb  ru  rd  r  r  r  r  r  r  r9   r:   r;   <module>r     s   $ "        
  >	 	 	        ( w + HI
T]Ty~}S/AABCt_2r6"= =D'9 D3		 
 8 
 ?B$'&)
 	"-" <" "	"
 $" "	" " " 
"  
 G ?B$'&)
 	GG <G "	G
 $G G	G G BG 
G" 8<$(4! 
C*9
!O
% !	 $  *2*2**2 
*2Z(
 * 	
  ,0^"-J!!#&!!(&
#&
)& !& 	&. @0$H 0$f%  * ,- */ , 5  
 5E+36=CQ F 54H#6+#636#6=C#6)#6 I#6L '# 	7 Y
HYQ  "M  24 . 3 MM MM` !) !)H )/	) % $#
  #
L T")
)
))
 #)
X
4
+  &	  ($ .2,*,, $D1. 2.b
'B #)	# 
0* &
+ '.8*<+&    * i 0G( ! i.+ /+
3
% , , + + i  !$ i  !r:   