o
    Zh3-                     @  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mZ ddlmZ ddl	Z	ddl
m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ZejjZdXddZG dd dejZejZded< dYddZdYddZdYddZdZd[d!d"Zd\d$d%Z d&d'dd(d]d0d1Z!d^d3d4Z"d5d6 e#d7D Z$e$%e&d8d9e&d:d;e&d<d=i d_d@dAZ'ej(G dBdC dCZ)dDdE Z*dFdG Z+dHdI Z,d`dLdMZ-dadOdPZ.dbdRdSZ/dcdVdWZ0dS )dz"Python version compatibility code.    )annotationsN)	Parameter)	signature)Path)Any)Callable)Final)NoReturn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   E/var/www/html/lang_env/lib/python3.10/site-packages/_pytest/compat.pylegacy_path    s   r   c                   @  s   e Zd ZdZdS )
NotSetTyper   N)__name__
__module____qualname__tokenr   r   r   r   r   (   s    r   r   NOTSETfuncobjectboolc                 C  s   t | }|ot|  S N)inspectisgeneratorfunctioniscoroutinefunction)r   Zgenfuncr   r   r   is_generator.   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).
    Z_is_coroutineF)r   r   getattrr   r   r   r   r   3   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_function?   s   r"   curdirstr | os.PathLike[str] | Nonestrc                 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)functionr#   fnlinenoZrelfnr   r   r   getlocationE   s   r0   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   ZmockDEFAULTzunittest.mockc                   s*   g | ]}|j s|j u s|ju r|qS r   )Zattribute_namenew.0pZmock_sentinelZut_mock_sentinelr   r   
<listcomp>]   s    z'num_mock_patch_args.<locals>.<listcomp>)r   sysmodulesgetr   len)r-   r2   r   r8   r   num_mock_patch_argsS   s   r>    F)name	is_methodclsr-   Callable[..., object]r@   rA   rB   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)Z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emptyr@   r5   r   r   r   	<genexpr>   s    z"getfuncargnames.<locals>.<genexpr>)rK   r&   __wrapped__)r   
parametersr,   	TypeError_pytest.outcomesrF   tuplevaluesr   
isinstancer   getattr_staticstaticmethodhasattrr>   )r-   r@   rA   rB   rO   erF   	arg_namesr   r   r   getfuncargnamesf   s4   	
rZ   Callable[..., Any]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   rG   r5   r   r   r   rM      s    z(get_default_arg_names.<locals>.<genexpr>)rR   r   rO   rS   )r-   r   r   r   get_default_arg_names   s   r\   c                 C  s(   i | ]}|t d dvr|d|dqS )       z\x02x)range)r6   ir   r   r   
<dictcomp>   s    "rb      	z\tz\r
z\nvalbytes | strc                 C  s2   t | tr| dd}n| 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 strings 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.
    asciibackslashreplaceunicode_escape)rT   bytesdecodeencode	translate$_non_printable_ascii_translate_table)rg   retr   r   r   ascii_escaped   s   

rr   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   rs      s   
 rs   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|| d||  t| tj	rD| j
} | S )	zjGet the real function object of the (possibly) wrapped object by
    functools.wraps or functools.partial.d   Z__pytest_wrapped__NrN   r   )safereprz could not find real function of z
stopped at )r`   r   rT   rs   rt   Z_pytest._io.safereprrx   r,   	functoolspartialr   )rt   Z	start_objra   Znew_objrx   r   r   r   r'      s"   
r'   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__)rW   r'   	Exceptioncallabler|   )rt   ZholderrA   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   	getimfunc  s
   r   r   rK   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)rQ   r   r   )r   r@   rK   r   r   r   r   safe_getattr  s   	r   rt   c                 C  s"   zt | W S  ty   Y dS w )z0Ignore any exception via isinstance on Python 3.F)r   isclassr}   )rt   r   r   r   safe_isclass$  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.
    win32Z
emscriptenN)r:   platformosgetuid)ERRORuidr   r   r   get_user_id,  s
   	r   valuer	   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%   )r   r1   )
r-   rC   r@   r%   rA   r   rB   rD   r   rE   )r-   r[   r   rE   )rg   rh   r   r%   )r   r   r@   r%   rK   r   r   r   )rt   r   r   r   )r   r   )r   r	   r   r	   )1ru   
__future__r   dataclassesenumry   r   r   r   r   pathlibr   r:   typingr   r   r   r	   pyr
   localr   r   Enumr   r   r   rv   r   r   r"   r0   r>   rZ   r\   r`   rp   updateordrr   	dataclassrs   r'   r   r   r   r   r   r   r   r   r   r   <module>   s\   





F



4