a
    !fE5                     @  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rddlmZ edZedZejjZdddddZG dd dejZej Z!de"d< ej#dkr6ddl$Z%e%j&Z'nddl'Z'dddddZ(d d!dd"d#Z)d d!dd$d%Z*d d!dd&d'Z+djd(dd)d*d+Z,d,d-d.d/Z-d0d1dd2ddd!d3d4d5d6d7Z.dd4d8d9d:Z/d;d< e0d=D Z1e12e3d>d?e3d@dAe3dBdCi dddDdEdFZ4e5e6fZ7dGddHdIdJZ8dKddHdLdMZ9ej:G dNdO dOZ;dPdQ Z<dRdS Z=dTdU Z>dVddVdVdWdXdYZ?d d!dZd[d\Z@erej#dkrdd]lmAZA ndd]lmAZA n"ej#dkrdd]lmAZA nd^d_ ZAej#dkrdd`lmBZB nG dadb dbeeef ZBdcd-dddeZCdfdfdgdhdiZDdS )kz"Python version compatibility code.    )annotationsN)	Parameter)	signature)Path)Any)Callable)Generic)NoReturn)TYPE_CHECKING)TypeVar)overload)Final_T_Szstr | os.PathLike[str]LEGACY_PATH)pathreturnc                 C  s   t | S )zBInternal wrapper to prepare lazy proxies for legacy_path instances)r   )r    r   O/var/www/html/python-backend/venv/lib/python3.9/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)      zCallable[..., Any]strfuncr   c                 C  s   t t| S N)r   r   r    r   r   r   _format_argsE   s    r#   objectboolc                 C  s   t | }|ot|  S r!   )inspectisgeneratorfunctioniscoroutinefunction)r    Z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    r-   z
str | None)curdirr   c                 C  sh   t | } tt| }| jj}|d urXz||}W n tyF   Y n0 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   getlocation`   s    r9   int)r   c                   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>x   s   z'num_mock_patch_args.<locals>.<listcomp>)r+   sysmodulesgetr$   len)r6   r;   r   rA   r   num_mock_patch_argsn   s    rG    F)name	is_methodclsztype | Noneztuple[str, ...])r6   rI   rJ   rK   r   c             
   C  s   zt | j}W nL ttfyZ } z0ddlm} |d| d| dd W Y d}~n
d}~0 0 tdd	 | D }|s|| j}|s|rt	t
j||dd
ts|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  s8   | ]0}|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emptyrI   r>   r   r   r   	<genexpr>   s
   z"getfuncargnames.<locals>.<genexpr>)rQ   r/   __wrapped__)r   
parametersr5   	TypeError_pytest.outcomesrL   tuplevaluesr   
isinstancer&   getattr_staticstaticmethodhasattrrG   )r6   rI   rJ   rK   rU   erL   	arg_namesr   r   r   getfuncargnames   s0    	
r`   )r6   r   c                 C  s   t dd t| j D S )Nc                 s  s2   | ]*}|j tjtjfv r|jtjur|jV  qd S r!   rM   r>   r   r   r   rS      s   z(get_default_arg_names.<locals>.<genexpr>)rX   r   rU   rY   )r6   r   r   r   get_default_arg_names   s    ra   c                 C  s(   i | ] }|t d dvr|d|dqS )       z\x02x)range)r?   ir   r   r   
<dictcomp>   s   rg      	z\tz\r
z\n)sr   c                 C  s
   |  tS r!   )	translate$_non_printable_ascii_translate_table)rl   r   r   r   _translate_non_printable   s    ro   bytes)valr   c                 C  s   |  ddS )Nasciibackslashreplace)decode)rq   r   r   r   _bytes_to_ascii   s    ru   zbytes | strc                 C  s,   t | trt| }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 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_escaperr   )rZ   rp   ru   encodert   ro   )rq   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r0|j}  qtt| dd}|du rH qt|} qddlm} tdj|||| dt| t	j
r| j} | S )	zjGet the real function object of the (possibly) wrapped object by
    functools.wraps or functools.partial.d   Z__pytest_wrapped__NrT   r   )safereprz<could not find real function of {start}
stopped at {current})startcurrent)re   r+   rZ   rz   r{   Z_pytest._io.safereprr   r5   format	functoolspartialr    )r{   Z	start_objrf   Znew_objr   r   r   r   r0   
  s&    
r0   c                 C  sT   zt | d}t| } W n ty,   |  Y S 0 |rPt | drPt| jrP| |} | 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]   r0   	Exceptioncallabler   )r{   ZholderrJ   r   r   r   get_real_method'  s    


r   c                 C  s$   z| j W S  ty   |  Y S 0 d S r!   )r   AttributeErrorr"   r   r   r   	getimfunc5  s    r   r   )r$   rI   rQ   r   c                 C  s6   ddl m} zt| ||W S  |y0   | Y S 0 dS )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_OUTCOMEN)rW   r   r+   )r$   rI   rQ   r   r   r   r   safe_getattr<  s
    	r   )r{   r   c                 C  s&   zt | W S  ty    Y dS 0 dS )z0Ignore any exception via isinstance on Python 3.FN)r&   isclassr   )r{   r   r   r   safe_isclassM  s    r   )finalc                 C  s   | S r!   r   )fr   r   r   r   ^  s    r   )cached_propertyc                   @  sZ   e Zd ZdZdddddZedddd	d
ddZeddddd
ddZdddZdS )r   r    r|   zCallable[[_S], _T]Noner   c                 C  s   || _ |j| _d S r!   r   )selfr    r   r   r   __init__i  s    zcached_property.__init__.ztype[_S] | Nonezcached_property[_S, _T])instanceownerr   c                 C  s   d S r!   r   r   r   r   r   r   r   r   m  s    zcached_property.__get__r   r   c                 C  s   d S 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    ).).)N)r   r   r   	__slots__r   r   r   r   r   r   r   r   f  s    r   z
int | Nonec                  C  s8   t jdkst jdkrdS d} t }|| kr0|S d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)rC   platformosgetuid)ERRORuidr   r   r   get_user_id~  s
    	r   r	   )r   r   c                 C  s$   ds J d|  dt | j dd S )NFzUnhandled value: z ())typer   )r   r   r   r   assert_never  s    r   )N)Er|   
__future__r   dataclassesenumr   r&   r   rC   r   r   pathlibr   typingr   r   r   r	   r
   r   pyr   Ztyping_extensionsr   r   r   r   localr   r   Enumr   r   r   r}   version_infoimportlib.metadata	importlibmetadataimportlib_metadatar#   r)   r(   r-   r9   rG   r`   ra   re   rn   updateordro   rp   r   ZSTRING_TYPESru   ry   	dataclassrz   r0   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s   
F4