o
    #6d                     @  s  U d dl mZ d dlmZ d dlmZmZ d dl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 ddlmZ dad	ed
< d3ddZed4ddZd5ddZd6dd Zejd!d"d7d&d'Zejd!d"d8d*d+Zeje d,d9d-d.Zejd:d/d0Zejd;d1d2Z dS )<    )annotations)contextmanager)isasyncgenfunctioniscoroutinefunction)AnyDict	GeneratorTuplecastN   )get_all_backendsget_asynclib)
TestRunnerzTestRunner | None_current_runnerbackendobjectreturntuple[str, dict[str, Any]]c                 C  sf   t | tr	| i fS t | tr/t| dkr/t | d tr/t | d tr/ttttttf f | S t	d)N   r   r   z@anyio_backend must be either a string or tuple of (string, dict))

isinstancestrtuplelendictr
   r	   r   r   	TypeError)r    r   jC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\anyio/pytest_plugin.pyextract_backend_and_options   s   
r   backend_namer   backend_optionsdict[str, Any]#Generator[TestRunner, object, None]c              	   c  s    t rt V  d S t| }d }tjd d u rtj| }z0|p i }|jdi |}|a |V  W d    n1 s9w   Y  W d a |rKtj| d S d S d a |rXtj| w w )Nr   )r   r   sniffioZcurrent_async_library_cvargetsetr   reset)r   r   Zasynclibtokenrunnerr   r   r   
get_runner   s.   r(   configr   Nonec                 C  s   |  dd d S )NmarkerszManyio: mark the (coroutine function) test to be run asynchronously via anyio.)Zaddinivalue_line)r)   r   r   r   pytest_configure4   s   r,   
fixturedefrequestc                   s`    fdd}| j  t st r,d|jv r*d| jv || _ s.|  jd7  _d S d S d S d S )Nc                 ?  s    t | \}}r| |d< t||&}t r!| |E d H  n| |V  W d    d S W d    d S 1 s;w   Y  d S )Nanyio_backend)r   r(   r   Zrun_asyncgen_fixtureZrun_fixture)r/   argskwargsr   r   r'   funcZhas_backend_argr   r   wrapper=   s   "z%pytest_fixture_setup.<locals>.wrapperr/   r/   )r3   r   r   Zfixturenamesargnames)r-   r.   r4   r   r2   r   pytest_fixture_setup<   s   

r7   T)Ztryfirst	collectornameobjc                 C  sv   |  ||r5t|dr|jjn|}t|r7| d}t|dd}|s+tdd |D r9tj	
d| d S d S d S d S )N
hypothesisanyioZ
pytestmarkr   c                 s  s    | ]}|j d kV  qdS )r<   N)r9   ).0markerr   r   r   	<genexpr>Z   s    z,pytest_pycollect_makeitem.<locals>.<genexpr>r/   )Zistestfunctionhasattrr;   
inner_testr   Zget_closest_markergetattranypytestmarkZusefixtures)r8   r9   r:   Z
inner_funcr>   Zown_markersr   r   r   pytest_pycollect_makeitemS   s   
rF   
pyfuncitembool | Nonec                   s   d fdd}| j d}|ret|\ t| jdr3| jjjj|jkr1tr1|| jj_d S t| jre| j fd	d
| j	j
D }t }|| j| W d    dS 1 s^w   Y  dS d S )Nr1   r   r   r*   c                    s<   t  }||  W d    d S 1 sw   Y  d S N)r(   run_test)r1   r'   )r   r   original_funcr   r   run_with_hypothesis`   s   "z/pytest_pyfunc_call.<locals>.run_with_hypothesisr/   r;   c                   s   i | ]}| | qS r   r   )r=   arg)funcargsr   r   
<dictcomp>s   s    z&pytest_pyfunc_call.<locals>.<dictcomp>T)r1   r   r   r*   )rN   r#   r   r@   r:   r;   rA   __qualname__r   Z_fixtureinfor6   r(   rJ   )rG   rL   r   Ztestargsr'   r   )r   r   rN   rK   r   pytest_pyfunc_call^   s(   



rQ   )paramsc                 C  s   | j S rI   )param)r.   r   r   r   r/   |   s   r/   c                 C  s   t | tr| S | d S )Nr   r   r   r5   r   r   r   anyio_backend_name      
rU   c                 C  s   t | tri S | d S )Nr   rT   r5   r   r   r   anyio_backend_options   rV   rW   )r   r   r   r   )r   r   r   r    r   r!   )r)   r   r   r*   )r-   r   r.   r   r   r*   )r8   r   r9   r   r:   r   r   r*   )rG   r   r   rH   )r.   r   r   r   )r/   r   r   r   )r/   r   r   r    )!
__future__r   
contextlibr   inspectr   r   typingr   r   r   r	   r
   rD   r"   Z_core._eventloopr   r   abcr   r   __annotations__r   r(   r,   r7   ZhookimplrF   rQ   Zfixturer/   rU   rW   r   r   r   r   <module>   s0    






