a
    /§»aü  ã                   @   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 u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   úJ/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/_pytest/outcomes.pyr      s    ÿzOutcomeException.__init__)r   c                 C   s    | j d u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   r0   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    r5   Ú__annotations__r3   r   r   r   r   r6   Z   s   
r6   )Úexception_typer   c                    s    t tt tf dœ‡ fdd„}|S )N)Úfuncr   c                    s   t tttf | ƒ}ˆ |_|S r.   )r   r6   r3   r5   r7   )r;   Zfunc_with_exception©r:   r   r   Údecorate`   s    z!_with_exception.<locals>.decorate)r3   r6   r5   )r:   r=   r   r<   r   Ú_with_exception_   s    r>   r   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   Úexitk   s    r@   Ú ©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&   r?   r   r   r   Úskipv   s    rC   Tr   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.
    Tr'   N)r(   )r   r   r?   r   r   r   ÚfailŽ   s    
rD   c                   @   s   e Zd ZdZdS )ÚXFailedz/Raised from an explicit call to pytest.xfail().Nr)   r   r   r   r   rE   œ   s   rE   )Ú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)rE   )rF   r?   r   r   r   Úxfail    s    rG   )ÚmodnameÚ
minversionrF   r   c           	      C   s  ddl }d}t| ddƒ | ¡ �r | d¡ zt| ƒ W nJ ty‚ } z2|du r`d| ›d|› �}t|dd	�d‚W Y d}~n
d}~0 0 W d  ƒ n1 s˜0    Y  tj|  }|du r¸|S t	|d
dƒ}|du�r
ddl
m} |du sô||ƒ||ƒk �r
t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   NTrA   ÚevalÚignorezcould not import z: rB   Ú__version__)ÚVersionz-module %r has __version__ %r, required is: %r)ÚwarningsÚcompileÚcatch_warningsÚsimplefilterÚ
__import__ÚImportErrorr$   ÚsysÚmodulesÚgetattrZpackaging.versionrM   )	rH   rI   rF   rN   r?   ÚexcÚmodZverattrrM   r   r   r   Úimportorskip¯   s2    

B

ÿýrY   )N)rA   )rA   T)rA   )NN)#r!   rT   Útypingr   r   r   r   r   r   ÚTYPE_CHECKINGr   Ztyping_extensionsr	   r
   r   r   r7   ZTEST_OUTCOMEr$   r(   r*   Úobjectr3   r5   r6   r>   r   r1   r@   r"   rC   rD   rE   rG   rY   r   r   r   r   Ú<module>   sH   "
 ÿþ