
    Oj8                       U d dl mZ d dlZd dlZd dlZd dlmZmZmZ d dl	m
Z
mZ d dlmZmZmZ d dlmZmZmZ d dlZd dlmZmZ d dlmZ d d	lmZ d
dlmZ d
dlmZm Z m!Z!m"Z" d
dl#m$Z$ erd
dl%m&Z& ejN                  dk  rd dl(m)Z) erd dl*m+Z, n	 d dl*m,Z, da.de/d<   da0de/d<   d a1d0dZ2e	 	 	 	 	 	 d1d       Z3d2dZ4d3dZ5d4dZ6 ejn                  d      d5d       Z8 ejn                  d      	 	 	 	 	 	 	 	 d6d        Z9d7d"Z: ejn                  d      d8d#       Z; ejx                  d$ e       %      d9d&       Z=ejx                  d:d'       Z>ejx                  d;d(       Z? G d) d*      Z@ ejx                  d!+      d<d,       ZA ejx                  d!+      d<d-       ZBejx                  d=d.       ZCejx                  d>d/       ZDy# e-$ r
 d dl*m+Z, Y Bw xY w)?    )annotationsN)Callable	GeneratorIterator)	ExitStackcontextmanager)isasyncgenfunctioniscoroutinefunctionismethod)TYPE_CHECKINGAnycast)FuncFixtureInfo
SubRequest)Exit)Scope   )get_available_backends)current_async_libraryget_async_backendreset_current_async_libraryset_current_async_library)iterate_exceptions)
TestRunner)      )ExceptionGroup)	CallSpec2)CallSpeczTestRunner | None_current_runnerzExitStack | None_runner_stackc                   t        | t              r| i fS t        | t              r^t        |       dk(  rPt        | 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   	TypeError)backends    j/var/www/origus_pro_usr/data/www/origus.pro/core/.venv/lib/python3.12/site-packages/anyio/pytest_plugin.pyextract_backend_and_optionsr,   /   sq    '3{	GU	#G(9gaj#&:gaj$+Gc4S>12G<<
V
WW    c              #    K   t         nt        |       }t               at	               %t        |       }t        j                  t        |       |xs i }t        j                  |j                  |            a t        dz  a
	 t          t        dz  a
t        s!t        J t        j                          d xaa y y # t        dz  a
t        s!t        J t        j                          d xaa w w xY wwNr   )r    r   r   r!   r   r   callbackr   enter_contextcreate_test_runner_runner_leasesclose)backend_namebackend_optionsasynclibtokens       r+   
get_runnerr9   9   s     
 $\2! "* .l;E""#>F)/R'55''8
 aN3! ,,,!.22MO  	! ,,,!.22MO s   A>C/B: 	1C/:2C,,C/c                x    | j                  d      }| j                  ddd       |j                  dd dd       y )	Nanyio
anyio_modestrictz-AnyIO plugin mode (either "strict" or "auto"))defaulthelpz--anyio-modez
        'auto'   - All async test functions will be handled by AnyIO pytest plugin
        'strict' - Disabling autoprocessing(useful when anyio tests
            need to coexist with other async test plugins)
        )r>   destr?   )getgroupaddini	addoption)parsergroups     r+   pytest_addoptionrF   W   sK    OOG$E
MM<  
 
OO	  	r-   c                Z    | j                  |d       dk(  xs | j                  |      dk(  S )N)r>   auto)	getoptiongetini)configmodes     r+   _is_auto_moderM   j   s3    t,6W&--:MQW:Wr-   c                    | j                  dd       t        | d      rO| j                  j                  d      r3t        | d      r&| j	                  t        j                  d      d       y y y y )NmarkerszManyio: mark the (coroutine function) test to be run asynchronously via anyio.r<   asyncioasyncio_modezlAnyIO auto mode has been enabled together with pytest-asyncio auto mode. This may cause unexpected behavior.r   )addinivalue_linerM   pluginmanager
has_pluginissue_config_time_warningpytestPytestConfigWarning)rK   s    r+   pytest_configurerX   p   su    
W
 	fl+  ++I6&.1((&&< 	
 2 7 	,r-   T)hookwrapperc              #    K   dfd}| j                   t              st              r~d|j                  v rp|| _         | j                  }d| j                  v xs| xj                  dz  c_        d| j                  v xs| xj                  dz  c_        	 d | _         || _        S d S # | _         || _        w xY ww)Nanyio_backendrequestc              ;    K   |j                   r[t              rPt        j                        t        |j                         u r&j                  j                  |j                         }n}t        |       \  }}r| |d<   	r||d<   t        ||      5 }|j                         rt        d      t        |      r|j                  ||      E d {    n|j                  ||       d d d        y 7 "# 1 sw Y   y xY ww)Nr[   r\   zCannot schedule a coroutine in the test runner while another is already running; likely caused by request.getfixturevalue() on an async fixture.)instancer   type__self____func____get__r,   r9   
is_runningRuntimeErrorr	   run_asyncgen_fixturerun_fixture)
r[   r\   kwargs
local_funcr5   r6   runnerfunchas_backend_arghas_request_args
          r+   wrapperz%pytest_fixture_setup.<locals>.wrapper   s      T]]#tG,<,<'==..w/?/?@JJ(CM(R%o&3F?# 'F9o6 	=&   ""V 
 "*-!66z6JJJ((V<<!	= 	= K	= 	=s0   BD<C6C4C6+	D4C66C?;Dr[   r\   )r[   r   r\   r   rg   r   returnr   )rj   r	   r
   fixturenamesargnames)
fixturedefr\   rm   original_argnamerj   rk   rl   s       @@@r+   pytest_fixture_setupru      s     "=L ??D$#6t#<g222%JO)22'6*:M:M'MMOM##'99#'0J4G4G'GGOG##|3#7"&
&6
#N #'
&6
#s   BCB2 C2CC)tryfirstc                h   | j                  ||      rt        |d      r|j                  j                  n|}t	        |      rpt        | j                  d      }| j                  d      }t        |dd      }|s|st        d |D              r%t        j                  j                  d      |       y y y y )N
hypothesisr<   r;   
pytestmark c              3  :   K   | ]  }|j                   d k(    yw)r;   N)name).0markers     r+   	<genexpr>z,pytest_pycollect_makeitem.<locals>.<genexpr>   s     H&v{{g-Hs   r[   )istestfunctionhasattrrx   
inner_testr
   rM   rK   get_closest_markergetattranyrV   markusefixtures)	collectorr|   obj
inner_funcanyio_auto_moder~   own_markerss          r+   pytest_pycollect_makeitemr      s     T*29#|2LS^^..RU
z*+I,<,<lKO11':F!#|R8KHKHH''8= I + +r-   sessionc                P   t        t        t        | j                                    D ]  \  }}t	        |t
        j                        s"t        |j                        s8|j                  d      Jd|j                  vsYg }	 t        j                  t              D ch c]  }|j                   }}t        t#                     D ](  \  }}d|v r&t        d|id|idt$        j&                  i|gg       }n&t        i d|id|idt$        j&                  i|gg       }|j(                  }	t        |	j*                        }
d|
vr|
j-                  d       t/        |	j0                  |	j2                  |
|	j4                        }t
        j                  j7                  |j8                  |j:                   d| d||j<                  ||j>                  |j:                  	      }|j-                  |       + || j                  ||d
z     y c c}w # t        $ r t!               }Y pw xY w)Nr;   r[   
_arg2scope)paramsindicesr   _idlistmarks)funcargsr   r   	arg2scopeidlistr   )rr   initialnamesnames_closurename2fixturedefs[])r|   callspeccallobjfixtureinfokeywordsoriginalnamer   ) reversedlist	enumerateitemsr$   rV   Functionr
   functionr   rq   dataclassesfieldsr   r|   r)   setr   r   Module_fixtureinfor   appendr   rr   r   r   from_parentparentr   r   r   )r   iitem	new_itemsf	cs_fieldsparam_indexr*   r   finew_names_closurenew_fixtureinfonew_items                r+   pytest_collection_finishr      s	   D7==!9:; 614tV__-#DMM2''0<t'8'88I"-8-?-?-IJQVVJ	J )22H2J(K '+$W9,' /9!0+ >$3U\\#B!(	  H  (!# /9!0+ >#2ELL"A 'y  H &&$()9)9$:!"*;;%,,_="1[[!#"3%'%8%8	# "??66KK --.ay:% HH /!]]!%!2!2 7    *O'+R (1GMM!a!e$m61 K "E	"s$   HH	2H	HH%$H%c           	       	
 d	
fd}| j                   j                  d      }|r t        |      \  	
t        | j                  d      r`| j                  j
                  j                  j                  |j                  k7  r&t              r|| j                  j
                  _        y t        | j                        rg| j                   }| j                  j                  D ci c]  }|||   
 }}t        	
      5 }	 |j                  | j                  |       	 d d d        yy c c}w # t        $ r4}t        |      D ]   }t        |t         t"        t$        f      s||  d }~ww xY w# 1 sw Y   yxY w)Nc                 l    t              5 }|j                  |        d d d        y # 1 sw Y   y xY wN)r9   run_test)rg   ri   r5   r6   original_funcs     r+   run_with_hypothesisz/pytest_pyfunc_call.<locals>.run_with_hypothesis  s2    o6 	3&OOM62	3 	3 	3s   *3r[   rx   T)rg   r   rp   None)r   getr,   r   r   rx   r   __qualname__r
   r   rr   r9   r   r   r   r$   r   KeyboardInterrupt
SystemExit)
pyfuncitemr   r*   r   argtestargsri   excgrpexcr5   r6   r   s            @@@r+   pytest_pyfunc_callr     sQ   3 !!%%o6G(CG(L%o:>><0&NN55@@M))-@-M-MM&}5;NJNN--8z~~.!**H6@6M6M6V6VWsXc]*WHWL/: fOOJNNH=  X & 1&9 2%cD2CZ+PQ"%612  s6   'D+E0D00	E-9)E(#E((E--E00E9module)scoper   c                    | j                   S r   )paramro   s    r+   r[   r[   1  s    ==r-   c                0    t        | t              r| S | d   S )Nr   r$   r%   rn   s    r+   anyio_backend_namer   6  s    -%Qr-   c                0    t        | t              ri S | d   S r/   r   rn   s    r+   anyio_backend_optionsr   >  s    -%	Qr-   c                  4    e Zd ZdZddZedd       Zdd	dZy)
FreePortFactoryaO  
    Manages port generation based on specified socket kind, ensuring no duplicate
    ports are generated.

    This class provides functionality for generating available free ports on the
    system. It is initialized with a specific socket kind and can generate ports
    for given address families while avoiding reuse of previously generated ports.

    Users should not instantiate this class directly, but use the
    ``free_tcp_port_factory`` and ``free_udp_port_factory`` fixtures instead. For simple
    uses cases, ``free_tcp_port`` and ``free_udp_port`` can be used instead.
    c                >    || _         t        t                  | _        y r   )_kindr   int
_generated)selfkinds     r+   __init__zFreePortFactory.__init__T  s    
c(*r-   c                    | j                   S )z
        The type of socket connection (e.g., :data:`~socket.SOCK_STREAM` or
        :data:`~socket.SOCK_DGRAM`) used to bind for checking port availability

        )r   )r   s    r+   r   zFreePortFactory.kindX  s     zzr-   Nc                J   ||g}n@t         j                  g}t         j                  r|j                  t         j                         	 d}t               5 }|D ]r  }|j                  t        j                   || j                              }|t         j                  k(  rdnd}	 |j                  ||f       |r`|j                         d   }t || j                  vr&| j                  j                  |       |cddd       S ddd       # t        $ r Y  w xY w# 1 sw Y   xY w)z
        Return an unbound port for the given address family.

        :param family: if omitted, both IPv4 and IPv6 addresses will be tried
        :return: a port number

        Nr   z::1z	127.0.0.1r   )socketAF_INEThas_ipv6r   AF_INET6r   r1   r   bindOSErrorgetsocknamer   add)r   familyfamiliesportstackfamsockaddrs           r+   __call__zFreePortFactory.__call__a  s    xH'H0D $# $C ..v}}S$**/MND$'6??$:5D		4,/  #//1!4$ 4??2++D1#$ $ $  # $ $s7   AD!D	4D7?D		DDDDD")r   socket.SocketKindrp   r   )rp   r   r   )r   zsocket.AddressFamily | Nonerp   r   )__name__
__module__r   __doc__r   propertyr   r   rz   r-   r+   r   r   F  s%    %  $r-   r   )r   c                 4    t        t        j                        S r   )r   r   SOCK_STREAMrz   r-   r+   free_tcp_port_factoryr     s    6--..r-   c                 4    t        t        j                        S r   )r   r   
SOCK_DGRAMrz   r-   r+   free_udp_port_factoryr     s    6,,--r-   c                     |        S r   rz   )r   s    r+   free_tcp_portr          ""r-   c                     |        S r   rz   )r   s    r+   free_udp_portr     r   r-   )r*   objectrp   ztuple[str, dict[str, Any]])r5   r%   r6   dict[str, Any]rp   zIterator[TestRunner])rD   zpytest.Parserrp   r   )rK   pytest.ConfigrL   r%   rp   bool)rK   r  rp   r   )rs   r   r\   r   rp   zGenerator[Any])r   zpytest.Module | pytest.Classr|   r%   r   r   rp   r   )r   zpytest.Sessionrp   r   )r   r   rp   zbool | None)r\   r   rp   r   )r[   r   rp   r%   )r[   r   rp   r  )rp   r   )r   Callable[[], int]rp   r   )r   r  rp   r   )E
__future__r   r   r   syscollections.abcr   r   r   
contextlibr   r   inspectr	   r
   r   typingr   r   r   rV   _pytest.fixturesr   r   _pytest.outcomesr   _pytest.scoper    r   _core._eventloopr   r   r   r   _core._exceptionsr   abcr   version_infoexceptiongroupr   _pytest.pythonr   r   ImportErrorr    __annotations__r!   r3   r,   r9   rF   rM   rX   hookimplru   r   r   r   fixturer[   r   r   r   r   r   r   r   rz   r-   r+   <module>r     s5   "   
 9 9 0 E E + +  8 !  $  2g-49 	, &*" )"& &X 33(633 3:&
& T"9 #9x $>+>36>=C>	>  >"71t $!  !H h'='?@ A        :$ :$z i / !/ i . !. # # # #Y  9889s   G GG