a
    f	g3                     @  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   Q/var/www/html/llm_bihealth/app/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).
    Z_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    r8   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)r5   r:   r   r@   r   num_mock_patch_argsn   s    rF    F)name	is_methodclsztype | Noneztuple[str, ...])r5   rH   rI   rJ   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emptyrH   r=   r   r   r   	<genexpr>   s
   z"getfuncargnames.<locals>.<genexpr>)rP   r.   __wrapped__)r   
parametersr4   	TypeError_pytest.outcomesrK   tuplevaluesr   
isinstancer&   getattr_staticstaticmethodhasattrrF   )r5   rH   rI   rJ   rT   erK   	arg_namesr   r   r   getfuncargnames   s0    	
r_   )r5   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!   rL   r=   r   r   r   rR      s   z(get_default_arg_names.<locals>.<genexpr>)rW   r   rT   rX   )r5   r   r   r   get_default_arg_names   s    r`   c                 C  s(   i | ] }|t d dvr|d|dqS )       z\xZ02x)range)r>   ir   r   r   
<dictcomp>   s   re      	z\tz\r
z\n)sr   c                 C  s
   |  tS r!   )	translate$_non_printable_ascii_translate_table)rj   r   r   r   _translate_non_printable   s    rm   bytes)valr   c                 C  s   |  ddS )Nasciibackslashreplace)decode)ro   r   r   r   _bytes_to_ascii   s    rs   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_escaperp   )rY   rn   rs   encoderr   rm   )ro   retr   r   r   ascii_escaped   s    

rw   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   rx      s   
rx   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__NrS   r   )safereprz<could not find real function of {start}
stopped at {current})startcurrent)rc   r*   rY   rx   ry   Z_pytest._io.safereprr}   r4   format	functoolspartialr    )ry   Z	start_objrd   Znew_objr}   r   r   r   r/   
  s&    
r/   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\   r/   	Exceptioncallabler   )ry   ZholderrI   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$   rH   rP   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)rV   r   r*   )r$   rH   rP   r   r   r   r   safe_getattr<  s
    	r   )ry   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   )ry   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    rz   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  s&   t jdv rdS t } | dkr"| S dS )zYReturn the current user id, or None if we cannot get it reliably on the current platform.)win32Z
emscriptenN)rB   platformosgetuid)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)Erz   
__future__r   Zdataclassesenumr   r&   r   rB   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metadataZimportlib_metadatar#   r)   r(   r,   r8   rF   r_   r`   rc   rl   updateordrm   rn   r   ZSTRING_TYPESrs   rw   Z	dataclassrx   r/   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s   
F+