U
    `»{jË,  ã                   @  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dddœdd„ZG dd„ dejƒZejZded< dddœdd„Zdddœdd„Zdddœdd„ZdUdddœd d!„Zd"d#œd$d%„Z d&dd'œd(dd)d*d+œd,d-„Z!d.d*d/œd0d1„Z"d2d3„ e#d4ƒD ƒZ$e$ %e&d5ƒd6e&d7ƒd8e&d9ƒd:i¡ d;dd<œd=d>„Z'ej(G d?d@„ d@ƒƒZ)dAdB„ Z*dCdD„ Z+dEdF„ Z,dGddGdGdHœdIdJ„Z-dddKœdLdM„Z.dNd#œdOdP„Z/dQdQdRœdSdT„Z0dS )Vz"Python version compatibility code.é    )ÚannotationsN)Ú	Parameter)Ú	signature)ÚPath)ÚAny)ÚCallable)ÚFinal)ÚNoReturnz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   úM/var/www/html/bwave/python/venv/lib/python3.8/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ÚobjectÚbool)Úfuncr   c                 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 )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).
    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!   zstr | os.PathLike[str] | NoneÚstr)Úcurdirr   c                 C  sj   t | ƒ} tt | ¡ƒ}| jj}|d k	rZz| |¡}W n tk
rH   Y nX 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    r.   Ú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ˆ ks"|jˆk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+   r0   r   r6   r   Únum_mock_patch_argsS   s    þÿr<   Ú )ÚnameÚclszCallable[..., object]ztype | Noneztuple[str, ...])r+   r>   r?   r   c             
   C  s¾   zt | ƒj}W nJ ttfk
rX } z(ddlm} |d| ›d|› �dd� W 5 d}~X Y nX tdd	„ | ¡ D ƒƒ}|sz| j}|r t	t
j||dd
�tƒs |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)ZpytraceNc                 s  s8   | ]0}|j tjks|j tjkr|jtjkr|jV  qd S r   ©Úkindr   ÚPOSITIONAL_OR_KEYWORDÚKEYWORD_ONLYÚdefaultÚemptyr>   r3   r   r   r   Ú	<genexpr>Œ   s
   úz"getfuncargnames.<locals>.<genexpr>)rE   r$   Ú__wrapped__)r   Ú
parametersr*   Ú	TypeErrorÚ_pytest.outcomesr@   ÚtupleÚvaluesr   Ú
isinstancer   Úgetattr_staticÚstaticmethodÚhasattrr<   )r+   r>   r?   rI   Úer@   Ú	arg_namesr   r   r   Úgetfuncargnamesf   s0    þþ	ý ÿü
rT   zCallable[..., Any])r+   r   c                 C  s   t dd„ t| ƒj ¡ D ƒƒS )Nc                 s  s2   | ]*}|j tjtjfkr|jtjk	r|jV  qd S r   rA   r3   r   r   r   rG   ®   s   ýz(get_default_arg_names.<locals>.<genexpr>)rL   r   rI   rM   )r+   r   r   r   Úget_default_arg_namesª   s    þrU   c                 C  s(   i | ] }|t d dƒkr|d|d›�“qS )é    é   z\xÚ02x)Úrange)r4   Úir   r   r   Ú
<dictcomp>¶   s      r[   é€   ú	z\túz\rÚ
z\nzbytes | str)Úvalr   c                 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ÚbackslashreplaceZunicode_escape)rN   ÚbytesÚdecodeÚencodeÚ	translateÚ$_non_printable_ascii_translate_table)r`   Úretr   r   r   Úascii_escaped¾   s    
ri   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   rj   Õ   s   
rj   c                 C  sŒ   | }t dƒD ]@}t| ddƒ}t|tƒr0|j}  qvt| ddƒ}|dkrH qv|} qddlm} td||ƒ› 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__NrH   r   )Úsafereprz could not find real function of z
stopped at )rY   r   rN   rj   rk   Z_pytest._io.safereprro   r*   Ú	functoolsÚpartialr   )rk   Z	start_objrZ   Znew_objro   r   r   r   r%   á   s"    
ÿr%   c                 C  sV   zt | dƒ}t| ƒ} W n tk
r.   |  Y S X |rRt | dƒrRt| jƒrR|  |¡} | S )z»Attempt 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__)rQ   r%   Ú	ExceptionÚcallablers   )rk   ZholderZ	is_methodr   r   r   Úget_real_methodü   s    


rv   c                 C  s&   z| j W S  tk
r    |  Y S X d S r   )rr   ÚAttributeErrorr   r   r   r   Ú	getimfunc
  s    rx   r   )r   r>   rE   r   c                 C  s8   ddl m} zt| ||ƒW S  |k
r2   | Y S X 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)rK   ry   r   )r   r>   rE   ry   r   r   r   Úsafe_getattr  s
    	rz   )rk   r   c                 C  s(   zt  | ¡W S  tk
r"   Y dS X dS )z0Ignore any exception via isinstance on Python 3.FN)r   Úisclassrt   )rk   r   r   r   Úsafe_isclass"  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 )zšReturn 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éÿÿÿÿ)r8   ÚplatformÚosÚgetuid)ÚERRORÚuidr   r   r   Úget_user_id*  s
    	r„   r	   )Úvaluer   c                 C  s$   ds t d| › dt| ƒj› d�ƒ‚d S )NFzUnhandled value: z (ú))ÚAssertionErrorÚtyper   )r…   r   r   r   Úassert_never^  s    r‰   )N)1rl   Ú
__future__r   ÚdataclassesÚenumrp   r   r   r   r€   Úpathlibr   r8   Útypingr   r   r   r	   Úpyr   Úlocalr
   r   ÚEnumr   r   r   rm   r   r   r!   r.   r<   rT   rU   rY   rg   ÚupdateÚordri   Ú	dataclassrj   r%   rv   rx   rz   r|   r„   r‰   r   r   r   r   Ú<module>   sX   üDÿÿ4