o
    hE5                     @  s  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m	Z	 ddlm
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlZ	 ddlmZ erjddlmZ edZedZejjZdmddZG dd dejZej Z!de"d< ej#dkrddl$Z%e%j&Z'nddl'Z'dnd d!Z(dod$d%Z)dod&d'Z*dod(d)Z+dpdqd,d-Z,drd/d0Z-d1d2dd3dsd:d;Z.dtd<d=Z/d>d? e0d@D Z1e12e3dAdBe3dCdDe3dEdFi dudHdIZ4e5e6fZ7dvdLdMZ8dwdOdPZ9ej:G dQdR dRZ;dSdT Z<dUdV Z=dWdX Z>dxd[d\Z?dyd^d_Z@er.ej#dkr'dd`lmAZA ndd`lmAZA nej#dkr;dd`lmAZA ndadb ZAej#dkrLddclmBZB nG ddde deeeef ZBdzdgdhZCd{dkdlZDdS )|z"Python version compatibility code.    )annotationsN)	Parameter)	signature)Path)Any)Callable)Generic)NoReturn)TYPE_CHECKING)TypeVarT)overload)Final_T_Spathstr | os.PathLike[str]returnLEGACY_PATHc                 C  s   t | S )zBInternal wrapper to prepare lazy proxies for legacy_path instances)r   )r    r   D/var/www/html/ai/venv/lib/python3.10/site-packages/_pytest/compat.pylegacy_path0   s   r   c                   @  s   e Zd ZdZdS )
NotSetTyper   N)__name__
__module____qualname__tokenr   r   r   r   r   8   s    r   r   NOTSET)      funcCallable[..., Any]strc                 C  s   t t| S N)r!   r   r   r   r   r   _format_argsE      r$   objectboolc                 C  s   t | }|ot|  S r"   )inspectisgeneratorfunctioniscoroutinefunction)r   genfuncr   r   r   is_generatorI   s   
r,   c                 C  s   t | p
t| ddS )a{  Return True if func is a coroutine function (a function defined with async
    def syntax, and doesn't contain yield), or a function decorated with
    @asyncio.coroutine.

    Note: copied and modified from Python 3.5's builtin couroutines.py to avoid
    importing asyncio directly, which in turns also initializes the "logging"
    module as a side-effect (see issue #8).
    _is_coroutineF)r(   r*   getattrr#   r   r   r   r*   N   s   	r*   c                 C  s   t | pt| S )zZReturn True if the given function seems to be an async function or
    an async generator.)r*   r(   isasyncgenfunctionr#   r   r   r   is_async_functionZ   s   r0   curdir
str | Nonec                 C  sh   t | } tt| }| jj}|d ur,z||}W n	 ty#   Y n	w d||d f S d||d f S )Nz%s:%d   )get_real_funcr   r(   getfile__code__co_firstlinenorelative_to
ValueError)functionr1   fnlinenorelfnr   r   r   getlocation`   s   r>   intc                   sX   t | dd}|s
dS t tjddt  t tjddt t fdd|D S )	z>Return number of arguments used up by mock arguments (if any).	patchingsNr   mockDEFAULTzunittest.mockc                   s*   g | ]}|j s|j u s|ju r|qS r   )attribute_namenew.0pmock_sentinelut_mock_sentinelr   r   
<listcomp>x   s    z'num_mock_patch_args.<locals>.<listcomp>)r.   sysmodulesgetr&   len)r:   r@   r   rH   r   num_mock_patch_argsn   s   rP    F)name	is_methodclsr:   rR   rS   rT   type | Nonetuple[str, ...]c             
   C  s   zt | j}W n& ttfy- } zddlm} |d| d| dd W Y d}~nd}~ww tdd	 | D }|s>| j}|sM|rSt	t
j||dd
tsS|dd }t| dr`|t| d }|S )aL  Return the names of a function's mandatory arguments.

    Should return the names of all function arguments that:
    * Aren't bound to an instance or type as in instance or class methods.
    * Don't have default values.
    * Aren't bound with functools.partial.
    * Aren't replaced with mocks.

    The is_method and cls arguments indicate that the function should
    be treated as a bound method even though it's not unless, only in
    the case of cls, the function is a static method.

    The name parameter should be the original name in which the function was collected.
    r   )failz!Could not determine arguments of z: F)pytraceNc                 s  s:    | ]}|j tju s|j tju r|jtju r|jV  qd S r"   kindr   POSITIONAL_OR_KEYWORDKEYWORD_ONLYdefaultemptyrR   rE   r   r   r   	<genexpr>   s    z"getfuncargnames.<locals>.<genexpr>)r]   r3   __wrapped__)r   
parametersr9   	TypeError_pytest.outcomesrW   tuplevaluesr   
isinstancer(   getattr_staticstaticmethodhasattrrP   )r:   rR   rS   rT   ra   erW   	arg_namesr   r   r   getfuncargnames   s4   	
rl   c                 C  s   t dd t| j D S )Nc                 s  s4    | ]}|j tjtjfv r|jtjur|jV  qd S r"   rY   rE   r   r   r   r_      s    z(get_default_arg_names.<locals>.<genexpr>)rd   r   ra   re   )r:   r   r   r   get_default_arg_names   s   rm   c                 C  s(   i | ]}|t d dvr|d|dqS )       z\x02x)range)rF   ir   r   r   
<dictcomp>   s    "rs      	z\tz\r
z\nsc                 C  s
   |  tS r"   )	translate$_non_printable_ascii_translate_table)rx   r   r   r   _translate_non_printable   s   
r{   valbytesc                 C  s   |  ddS )Nasciibackslashreplace)decode)r|   r   r   r   _bytes_to_ascii   r%   r   bytes | strc                 C  s2   t | trt| }t|S | dd}t|S )a  If val is pure ASCII, return it as an str, otherwise, escape
    bytes objects into a sequence of escaped bytes:

    b'\xc3\xb4\xc5\xd6' -> r'\xc3\xb4\xc5\xd6'

    and escapes unicode objects into a sequence of escaped unicode
    ids, e.g.:

    r'4\nV\U00043efa\x0eMXWB\x1e\u3028\u15fd\xcd\U0007d944'

    Note:
       The obvious "v.decode('unicode-escape')" will return
       valid UTF-8 unicode if it finds them in bytes, but we
       want to return escaped bytes for any byte, even if they match
       a UTF-8 string.
    unicode_escaper~   )rf   r}   r   encoder   r{   )r|   retr   r   r   ascii_escaped   s
   
r   c                   @  s   e Zd ZU dZded< dS )_PytestWrappera%  Dummy wrapper around a function object for internal use only.

    Used to correctly unwrap the underlying function object when we are
    creating fixtures, because we wrap the function object ourselves with a
    decorator to issue warnings when the fixture function is called directly.
    r   objN)r   r   r   __doc____annotations__r   r   r   r   r      s   
 r   c                 C  s   | }t dD ] }t| dd}t|tr|j}  n"t| dd}|du r$ n|} qddlm} tdj|||| dt| t	j
rC| j} | S )	zjGet the real function object of the (possibly) wrapped object by
    functools.wraps or functools.partial.d   __pytest_wrapped__Nr`   r   )safereprz<could not find real function of {start}
stopped at {current})startcurrent)rq   r.   rf   r   r   _pytest._io.safereprr   r9   format	functoolspartialr   )r   	start_objrr   new_objr   r   r   r   r4   
  s&   
r4   c                 C  sT   zt | d}t| } W n ty   |  Y S w |r(t | dr(t| jr(| |} | S )zAttempt to obtain the real function object that might be wrapping
    ``obj``, while at the same time returning a bound method to ``holder`` if
    the original object was a bound method.__func____get__)ri   r4   	Exceptioncallabler   )r   holderrS   r   r   r   get_real_method'  s   

r   c                 C  s    z| j W S  ty   |  Y S w r"   )r   AttributeErrorr#   r   r   r   	getimfunc5  s
   r   r   r]   c                 C  s2   ddl m} zt| ||W S  |y   | Y S w )aR  Like getattr but return default upon any Exception or any OutcomeException.

    Attribute access can potentially fail for 'evil' Python objects.
    See issue #214.
    It catches OutcomeException because of #2490 (issue #580), new outcomes
    are derived from BaseException instead of Exception (for more details
    check #2707).
    r   )TEST_OUTCOME)rc   r   r.   )r&   rR   r]   r   r   r   r   safe_getattr<  s   	r   r   c                 C  s"   zt | W S  ty   Y dS w )z0Ignore any exception via isinstance on Python 3.F)r(   isclassr   )r   r   r   r   safe_isclassM  s
   r   )finalc                 C  s   | S r"   r   )fr   r   r   r   ^  s   r   )cached_propertyc                   @  sF   e Zd ZdZdddZe	ddddZeddddZdddZdS )r   r   r   r   Callable[[_S], _T]r   Nonec                 C  s   || _ |j| _d S r"   r   )selfr   r   r   r   __init__i  s   zcached_property.__init__.instanceownertype[_S] | Nonecached_property[_S, _T]c                 C     d S r"   r   r   r   r   r   r   r   r   m  s   zcached_property.__get__r   r   c                 C  r   r"   r   r   r   r   r   r   s  s   Nc                 C  s(   |d u r| S |  | }|j| j j< |S r"   )r   __dict__r   )r   r   r   valuer   r   r   r   w  s   )r   r   r   r   ).)r   r   r   r   r   r   )r   r   r   r   r   r   r"   )r   r   r   	__slots__r   r   r   r   r   r   r   r   f  s    
r   
int | Nonec                  C  s4   t jdks
t jdkrdS d} t }|| kr|S dS )zReturn the current process's real user id or None if it could not be
    determined.

    :return: The user id or None if it could not be determined.
    win32
emscriptenN)rL   platformosgetuid)ERRORuidr   r   r   get_user_id~  s
   	r   r   r	   c                 C  s   J d|  dt | j d)NFzUnhandled value: z ())typer   )r   r   r   r   assert_never  s   r   )r   r   r   r   )r   r    r   r!   )r   r&   r   r'   r"   )r1   r2   r   r!   )r   r?   )
r:   r    rR   r!   rS   r'   rT   rU   r   rV   )r:   r    r   rV   )rx   r!   r   r!   )r|   r}   r   r!   )r|   r   r   r!   )r&   r   rR   r!   r]   r   r   r   )r   r&   r   r'   )r   r   )r   r	   r   r	   )Er   
__future__r   dataclassesenumr   r(   r   rL   r   r   pathlibr   typingr   r   r   r	   r
   r   pyr   typing_extensionsr   r   r   r   localr   r   Enumr   r   r   r   version_infoimportlib.metadata	importlibmetadataimportlib_metadatar$   r,   r*   r0   r>   rP   rl   rm   rq   rz   updateordr{   r}   r!   STRING_TYPESr   r   	dataclassr   r4   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s    	







F





4