B
    ܇\                 @   s   d Z ddlmZ ddlmZ ddlmZ ddl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dddZee_dddZe
e_dddZee_G dd dejZdddZee_d ddZdS )!z[
exception classes and constants handling test outcomes
as well as functions creating them
    )absolute_import)division)print_functionNc               @   s&   e Zd ZdZdddZdd ZeZdS )	OutcomeExceptionzw OutcomeException and its subclass instances indicate and
        contain info about test and collection outcomes.
    NTc             C   s   t | | || _|| _d S )N)BaseException__init__msgpytrace)selfr   r	    r   /lib/python3.7/site-packages/_pytest/outcomes.pyr      s    zOutcomeException.__init__c             C   s6   | j r(| j }t|tr$|jddd}|S d| jjf S )NzUTF-8replace)errorsz<%s instance>)r   
isinstancebytesdecode	__class____name__)r
   valr   r   r   __repr__   s    
zOutcomeException.__repr__)NT)r   
__module____qualname____doc__r   r   __str__r   r   r   r   r      s   
r   c               @   s   e Zd ZdZdddZdS )SkippedbuiltinsNTFc             C   s   t j| ||d || _d S )N)r   r	   )r   r   allow_module_level)r
   r   r	   r   r   r   r   r   )   s    zSkipped.__init__)NTF)r   r   r   r   r   r   r   r   r   $   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   .   s   r   c                   s"   e Zd ZdZd fdd	Z  ZS )Exitz= raised for immediate program exits (no tracebacks/summaries)unknown reasonNc                s    || _ || _tt| | d S )N)r   
returncodesuperr   r   )r
   r   r    )r   r   r   r   7   s    zExit.__init__)r   N)r   r   r   r   r   __classcell__r   r   )r   r   r   4   s   r   c             C   s   d}t | |dS )z
    Exit 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   exit@   s    r$    c             K   sD   d}| dd}|r4dd | D }td|t| |ddS )	a7  
    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.

    :kwarg bool allow_module_level: allows this function to be called at
        module level, skipping the rest of the module. Default 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.
    Tr   Fc             S   s   g | ]}|qS r   r   ).0kr   r   r   
<listcomp>`   s    zskip.<locals>.<listcomp>z unexpected keyword arguments: {})r   r   N)popkeys	TypeErrorformatr   )r   kwargsr#   r   r*   r   r   r   skipN   s    r.   Tc             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 the msg represents the full failure information and no
        python traceback will be reported.
    T)r   r	   N)r   )r   r	   r#   r   r   r   failh   s    r/   c               @   s   e Zd ZdZdS )XFailedz0 raised from an explicit call to pytest.xfail() N)r   r   r   r   r   r   r   r   r0   w   s   r0   c             C   s   d}t | dS )ar  
    Imperatively xfail an executing test or setup functions 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)r0   )reasonr#   r   r   r   xfail{   s    
r2   c       	   	   C   s  ddl }d}t| dd d}| 6 |d yt|  W n tk
rT   d}Y nX W dQ R X |r|dkrvd| f }t|dd	tj|  }|dkr|S t	|d
d}|dk	ryddl
m} W n& tk
r   td| f dd	Y nX |dks||||k rtd| ||f dd	|S )a  Imports and returns 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 ``__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.
    r   NTr%   evalFignorezcould not import %r)r   __version__)parse_versionz\we have a required version for %r but can not import pkg_resources to parse version strings.z-module %r has __version__ %r, required is: %r)warningscompilecatch_warningssimplefilter
__import__ImportErrorr   sysmodulesgetattrZpkg_resourcesr6   )	modnameZ
minversionr1   r7   r#   Zshould_skipmodZverattrZpvr   r   r   importorskip   s@    






rB   )N)r%   )r%   T)r%   )NN)r   Z
__future__r   r   r   r=   r   r   	ExceptionZTEST_OUTCOMEr   r   r   r$   r.   r/   r0   r2   rB   r   r   r   r   <module>   s&   




