B
    `                 @   s  d 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	Z	e	rvdd
lm
Z
 ddlmZ nddlmZ eZG dd deZeefZG dd deZG dd deZG dd deZededef dZedee dZG dd deeef Zeeegeeef f dddZeed3eee ddd d!Zeed4d	d#eedd$d%d&Zeed5eedd(d)d*ZG d+d, d,eZ ee d6edd-d.d/Z!d7eee ee ed0d1d2Z"dS )8zZException classes and constants handling test outcomes as well as
functions creating them.    N)Any)Callable)cast)Optional)Type)TypeVarF)NoReturn)Protocol)Genericc               @   s:   e Zd ZdZd
ee eddddZeddd	ZeZ	dS )OutcomeExceptionzmOutcomeException and its subclass instances indicate and contain info
    about test and collection outcomes.NT)msgpytracereturnc             C   sN   |d k	r2t |ts2d}t|t| jt|jt| | || _|| _	d S )NzY{} expected string as 'msg' parameter, got '{}' instead.
Perhaps you meant to use a mark?)

isinstancestr	TypeErrorformattype__name__BaseException__init__r   r   )selfr   r   	error_msg r   X/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/_pytest/outcomes.pyr      s    zOutcomeException.__init__)r   c             C   s    | j d k	r| j S d| jj dS )N<z
 instance>)r   	__class__r   )r   r   r   r   __repr__(   s    
zOutcomeException.__repr__)NT)
r   
__module____qualname____doc__r   r   boolr   r   __str__r   r   r   r   r      s   r   c               @   s*   e Zd ZdZdee eeddddZdS )	SkippedbuiltinsNTF)r   r   allow_module_levelr   c             C   s   t j| ||d || _d S )N)r   r   )r   r   r%   )r   r   r   r%   r   r   r   r   8   s    zSkipped.__init__)NTF)r   r   r   r   r   r!   r   r   r   r   r   r#   3   s
     r#   c               @   s   e Zd ZdZdZdS )Failedz.Raised from an explicit call to pytest.fail().r$   N)r   r   r   r    r   r   r   r   r&   B   s   r&   c                   s0   e Zd ZdZdeee dd fddZ  ZS )Exitz=Raised for immediate program exits (no tracebacks/summaries).unknown reasonN)r   
returncoder   c                s   || _ || _t | d S )N)r   r)   superr   )r   r   r)   )r   r   r   r   K   s    zExit.__init__)r(   N)	r   r   r   r    r   r   intr   __classcell__r   r   )r   r   r'   H   s   
r'   _F.)bound_ETc               @   s   e Zd ZU eed< eed< dS )_WithException	Exception__call__N)r   r   r   r/   __annotations__r-   r   r   r   r   r0   Z   s   
r0   )exception_typer   c                s    t tt tf d fdd}|S )N)funcr   c                s   t tttf | } |_|S )N)r   r0   r-   r/   r1   )r5   Zfunc_with_exception)r4   r   r   decorate`   s    z!_with_exception.<locals>.decorate)r-   r0   r/   )r4   r6   r   )r4   r   _with_exception_   s    r7   r   )r   r)   r   c             C   s   d}t | |dS )zExit testing process.

    :param str msg: Message to display upon exit.
    :param int returncode: Return code to be used when exiting pytest.
    TN)r'   )r   r)   __tracebackhide__r   r   r   exitk   s    r9    )r%   )r   r%   r   c            C   s   d}t | |ddS )a-  Skip an executing test with the given message.

    This function should be called only during testing (setup, call or teardown) or
    during collection by using the ``allow_module_level`` flag.  This function can
    be called in doctests as well.

    :param bool allow_module_level:
        Allows this function to be called at module level, skipping the rest
        of the module. Defaults to False.

    .. note::
        It is better to use the :ref:`pytest.mark.skipif ref` marker when
        possible to declare a test to be skipped under certain conditions
        like mismatching platforms or dependencies.
        Similarly, use the ``# doctest: +SKIP`` directive (see `doctest.SKIP
        <https://docs.python.org/3/library/doctest.html#doctest.SKIP>`_)
        to skip a doctest statically.
    T)r   r%   N)r#   )r   r%   r8   r   r   r   skipv   s    r;   T)r   r   r   c             C   s   d}t | |ddS )a  Explicitly fail an executing test with the given message.

    :param str msg:
        The message to show the user as reason for the failure.
    :param bool pytrace:
        If False, msg represents the full failure information and no
        python traceback will be reported.
    T)r   r   N)r&   )r   r   r8   r   r   r   fail   s    
r<   c               @   s   e Zd ZdZdS )XFailedz/Raised from an explicit call to pytest.xfail().N)r   r   r   r    r   r   r   r   r=      s   r=   )reasonr   c             C   s   d}t | dS )at  Imperatively xfail an executing test or setup function with the given reason.

    This function should be called only during testing (setup, call or teardown).

    .. note::
        It is better to use the :ref:`pytest.mark.xfail ref` marker when
        possible to declare a test to be xfailed under certain conditions
        like known bugs or missing features.
    TN)r=   )r>   r8   r   r   r   xfail   s    r?   )modname
minversionr>   r   c       	      C   s   ddl }d}t| dd | f |d yt|  W nH tk
r } z*|dkrbd| d| }t|dd	dW dd}~X Y nX W dQ R X tj|  }|dkr|S t	|d
d}|dk	rddl
m} |dks||||k rtd| ||f dd	|S )a  Import and return the requested module ``modname``, or skip the
    current test if the module cannot be imported.

    :param str modname:
        The name of the module to import.
    :param str minversion:
        If given, the imported module's ``__version__`` attribute must be at
        least this minimal version, otherwise the test is still skipped.
    :param str reason:
        If given, this reason is shown as the message when the module cannot
        be imported.

    :returns:
        The imported module. This should be assigned to its canonical name.

    Example::

        docutils = pytest.importorskip("docutils")
    r   NTr:   evalignorezcould not import z: )r%   __version__)Versionz-module %r has __version__ %r, required is: %r)warningscompilecatch_warningssimplefilter
__import__ImportErrorr#   sysmodulesgetattrZpackaging.versionrE   )	r@   rA   r>   rF   r8   excmodZverattrrE   r   r   r   importorskip   s.    

*

rQ   )N)r:   )r:   T)r:   )NN)#r    rL   typingr   r   r   r   r   r   TYPE_CHECKINGr   Ztyping_extensionsr	   r
   r   r   r1   ZTEST_OUTCOMEr#   r&   r'   objectr-   r/   r0   r7   r   r+   r9   r!   r;   r<   r=   r?   rQ   r   r   r   r   <module>   sB   "
