o
    #if,                     @  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dVddZG dd dejZejZded< dWddZdWddZdWddZdXdYd!d"ZdZd$d%Z d&dd'd[d.d/Z!d\d1d2Z"d3d4 e#d5D Z$e$%e&d6d7e&d8d9e&d:d;i d]d>d?Z'ej(G d@dA dAZ)dBdC Z*dDdE Z+dFdG Z,d^dJdKZ-d_dMdNZ.d`dPdQZ/dadTdUZ0dS )bz"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   G/var/www/html/corbot_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   genfuncr   r   r   is_generator.   s   
r   c                 C  s   t | p
t| ddS )az  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 coroutines.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   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linenorelfnr   r   r   getlocationE   s   r3   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>]   s    z'num_mock_patch_args.<locals>.<listcomp>)r!   sysmodulesgetr   len)r/   r5   r   r=   r   num_mock_patch_argsS   s   rE    )nameclsr/   Callable[..., object]rG   rH   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}|rQt	t
j||dd
tsQ|dd }t| dr^|t| d }|S )a   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 cls arguments indicate that the function should be treated as a bound
    method even though it's not unless 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emptyrG   r:   r   r   r   	<genexpr>   s    z"getfuncargnames.<locals>.<genexpr>)rR   r(   __wrapped__)r   
parametersr.   	TypeError_pytest.outcomesrL   tuplevaluesr   
isinstancer   getattr_staticstaticmethodhasattrrE   )r/   rG   rH   rV   erL   	arg_namesr   r   r   getfuncargnamesf   s2   	
ra   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   rN   r:   r   r   r   rT      s    z(get_default_arg_names.<locals>.<genexpr>)rY   r   rV   rZ   )r/   r   r   r   get_default_arg_names   s   rc   c                 C  s(   i | ]}|t d dvr|d|dqS )       z\x02x)range)r;   ir   r   r   
<dictcomp>   s    "ri      	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)r[   bytesdecodeencode	translate$_non_printable_ascii_translate_table)rn   retr   r   r   ascii_escaped   s   

ry   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   rz      s   
 rz   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   __pytest_wrapped__NrU   r   )safereprz could not find real function of z
stopped at )rg   r!   r[   rz   r{   _pytest._io.safereprr   r.   	functoolspartialr   )r{   	start_objrh   new_objr   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__)r^   r)   	Exceptioncallabler   )r{   holder	is_methodr   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   rR   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)rX   r   r!   )r   rG   rR   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_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.
    win32
emscriptenN)rA   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   r4   )r/   rI   rG   r'   rH   rJ   r   rK   )r/   rb   r   rK   )rn   ro   r   r'   )r   r   rG   r'   rR   r   r   r   )r{   r   r   r   )r   r   )r   r	   r   r	   )1r|   
__future__r   dataclassesenumr   r   r   r   r   pathlibr   rA   typingr   r   r   r	   pyr
   localr   r   Enumr   r   r   r}   r   r   r$   r3   rE   ra   rc   rg   rw   updateordry   	dataclassrz   r)   r   r   r   r   r   r   r   r   r   r   <module>   sZ   





D



4