B
    `R/                 @   s  U d 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mZ ddlmZ ddlmZ ddlZddlmZ ddlmZ erddlmZ ddlmZ edZedZG dd dejZej Z!de"d< ej#dkrDddl$m%Z& nddl&Z&edef e'dddZ(e)e*dZ+e,e-dd d!Z.e,e-dd"d#Z/e,e-dd$d%Z0dcee' e'd&d'd(Z1e2d)d*d+Z3dd,dd-edef e'e-ee) ee'df d.d/d0Z4ej#d1k red2d3 Z5ndd4lm5Z5 edef ee'df d5d6d7Z6d8d9 e7d:D Z8e89e:d;d<e:d=d>e:d?d@i e'e'dAdBdCZ;e<e'fZ=e<e'dDdEdFZ>ee<e'f e'dDdGdHZ?ej@G dIdJ dJZAdKdL ZBdMdN ZCdOdP ZDee'eedQdRdSZEe,e-dTdUdVZFer2ej#dkr$ddWlmGZG nddWlmGZG n"ej#dkrLddWlmGZG ndXdY ZGej#dkrnddZlmHZH n0dd[lmIZI dd\lmJZJ G d]d^ d^eeef ZHd_d_d`dadbZKdS )dz"Python version compatibility code.    N)contextmanager)	Parameter)	signature)Path)Any)Callable)Generic)Optional)Tuple)TYPE_CHECKING)TypeVar)Union)fail)TEST_OUTCOME)NoReturn)Final_T_Sc               @   s   e Zd ZdZdS )
NotSetTyper   N)__name__
__module____qualname__token r   r   V/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/_pytest/compat.pyr   %   s   r   r   NOTSET)      )metadata.)funcreturnc             C   s   t t| S )N)strr   )r   r   r   r   _format_args0   s    r"    c             C   s   t | }|ot|  S )N)inspectisgeneratorfunctioniscoroutinefunction)r   Zgenfuncr   r   r   is_generator8   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&   getattr)r   r   r   r   r&   =   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$   isasyncgenfunction)r   r   r   r   is_async_functionI   s    r+   )curdirr    c             C   sj   t | } tt| }| jj}|d k	rZy||}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   getlocationO   s    r7   )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)mock_sentinelut_mock_sentinelr   r   
<listcomp>h   s   z'num_mock_patch_args.<locals>.<listcomp>)r)   sysmodulesgetobjectlen)r4   r8   r   )r=   r>   r   num_mock_patch_args]   s    rE   F)name	is_methodcls)r4   rF   rG   rH   r    c         
   C   s   yt | j}W n> ttfk
rL } ztd| d| dd W dd}~X Y nX tdd | D }|sn| j}|s|rt|j	
|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.
    z!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 )N)kindr   POSITIONAL_OR_KEYWORDKEYWORD_ONLYdefaultemptyrF   )r;   r<   r   r   r   	<genexpr>   s   z"getfuncargnames.<locals>.<genexpr>r-   __wrapped__)r   
parametersr3   	TypeErrorr   tuplevaluesr   
isinstance__dict__rB   staticmethodhasattrrE   )r4   rF   rG   rH   rP   e	arg_namesr   r   r   getfuncargnamesp   s     (
rZ   )r      c               c   s
   d V  d S )Nr   r   r   r   r   nullcontext   s    r\   )r\   )r4   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 )N)rI   r   rJ   rK   rL   rM   rF   )r;   r<   r   r   r   rN      s   z(get_default_arg_names.<locals>.<genexpr>)rR   r   rP   rS   )r4   r   r   r   get_default_arg_names   s    r]   c             C   s(   i | ] }|t d dkrd|d|qS )       z\xZ02x)range)r;   ir   r   r   
<dictcomp>   s   rb      	z\tz\r
z\n)sr    c             C   s
   |  tS )N)	translate$_non_printable_ascii_translate_table)rg   r   r   r   _translate_non_printable   s    rj   )valr    c             C   s   |  ddS )Nasciibackslashreplace)decode)rk   r   r   r   _bytes_to_ascii   s    ro   c             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.
    Zunicode_escaperl   )rT   bytesro   encodern   rj   )rk   retr   r   r   ascii_escaped   s    

rs   c               @   s   e Zd ZdZe Z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.
    N)r   r   r   __doc__attribobjr   r   r   r   rt      s   rt   c             C   s   | }xnt dD ]<}t| dd}t|tr0|j} P t| dd}|dkrFP |} qW 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__NrO   r   )safereprz<could not find real function of {start}
stopped at {current})startcurrent)r`   r)   rT   rt   rx   Z_pytest._io.safereprrz   r3   format	functoolspartialr   )rx   Z	start_objra   Znew_objrz   r   r   r   r.      s"    
r.   c             C   sR   yt | d}t| } W n tk
r*   | S X |rNt | drNt| jrN| |} | 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   )rx   ZholderrG   r   r   r   get_real_method  s    

r   c             C   s    y| j S  tk
r   | S X d S )N)r   AttributeError)r   r   r   r   	getimfunc'  s    r   )rC   rF   rL   r    c             C   s&   yt | ||S  tk
r    |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).
    N)r)   r   )rC   rF   rL   r   r   r   safe_getattr.  s    	r   )rx   r    c             C   s$   y
t | S  tk
r   dS X dS )z0Ignore any exception via isinstance on Python 3.FN)r$   isclassr   )rx   r   r   r   safe_isclass=  s    
r   )finalc             C   s   | S )Nr   )fr   r   r   r   N  s    r   )cached_property)overload)Typec               @   st   e Zd ZdZeegef ddddZedde	e
e  ddd	d
Zedee	e
e  eddd
Zddd
ZdS )r   )r   ru   N)r   r    c             C   s   || _ |j| _d S )N)r   ru   )selfr   r   r   r   __init__[  s    zcached_property.__init__.zcached_property[_S, _T])instanceownerr    c             C   s   d S )Nr   )r   r   r   r   r   r   r   _  s    zcached_property.__get__c             C   s   d S )Nr   )r   r   r   r   r   r   r   e  s    c             C   s(   |d kr| S |  | }|j| j j< |S )N)r   rU   r   )r   r   r   valuer   r   r   r   i  s    ).).)N)r   r   r   	__slots__r   r   r   r   r   r	   r   r   r   r   r   r   r   X  s   r   r   )r   r    c             C   s   dst d| t| jd S )NFzUnhandled value: {} ({}))AssertionErrorr}   typer   )r   r   r   r   assert_never  s    r   )N)Lru   enumr~   r$   rer@   
contextlibr   r   r   pathlibr   typingr   r   r   r	   r
   r   r   r   rv   Z_pytest.outcomesr   r   r   Ztyping_extensionsr   r   r   Enumr   r   r   __annotations__version_info	importlibr   Zimportlib_metadatar!   r"   r   compileZ
REGEX_TYPErC   boolr'   r&   r+   r7   intrE   rZ   r\   r]   r`   ri   updateordrj   rp   ZSTRING_TYPESro   rs   rg   rt   r.   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s   8 7