Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/testfixtures/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/testfixtures/__pycache__/shouldraise.cpython-37.pyc

B

R�X��@s>ddlmZddlmZdZGdd�de�ZGdd�d�ZdS)	�)�wraps)�
Comparisona+

    :param exception: This can be one of the following:

                      * `None`, indicating that an exception must be
                        raised, but the type is unimportant.

                      * An exception class, indicating that the type
                        of the exception is important but not the
                        parameters it is created with.

                      * An exception instance, indicating that an
                        exception exactly matching the one supplied
                        should be raised.

    :param unless: Can be passed a boolean that, when ``True`` indicates that
                   no exception is expected. This is useful when checking
                   that exceptions are only raised on certain versions of
                   Python.
c@s2eZdZdeZdZd
dd�Zdd�Zdd	�ZdS)�ShouldRaisezs
    This context manager is used to assert that an exception is raised
    within the context it is managing.
    NFcCs||_||_dS)N)�	exception�expected)�selfr�unless�r	�I/opt/alt/python37/lib/python3.7/site-packages/testfixtures/shouldraise.py�__init__'szShouldRaise.__init__cCs|S)Nr	)rr	r	r
�	__enter__+szShouldRaise.__enter__c	Cs�|dk	rt||�s||�}||_|jr�|jr�t|j�}||kr�t|�}t|j�}d||f}||kr�tt|��d��dg}|�	t|��d�dd��|d�
|�7}t|��q�|s�td��n|r�td|��dS)	Nz%s raised, %s expected�
z, attributes differ:����zNo exception raised!z %r raised, no exception expectedT)�
isinstance�raisedrrr�repr�print�str�split�extend�join�AssertionError)	r�type�actual�	tracebackZ
comparisonZrepr_actualZ
repr_expected�message�extrar	r	r
�__exit__.s,




zShouldRaise.__exit__)NF)	�__name__�
__module__�__qualname__�
param_docs�__doc__rrrrr	r	r	r
rs

rc@s&eZdZdeZddd�Zdd�ZdS)�should_raisez�
    A decorator to assert that the decorated function will raised
    an exception. An exception class or exception instance may be
    passed to check more specifically exactly what exception will be
    raised.
    NcCs||_||_dS)N)rr)rrrr	r	r
rVszshould_raise.__init__cst����fdd��}|S)Nc	s(t�j�j���||�WdQRXdS)N)rrr)�args�kw)r�targetr	r
�_should_raise_wrapper\sz4should_raise.__call__.<locals>._should_raise_wrapper)r)rr'r(r	)rr'r
�__call__Zszshould_raise.__call__)NN)rr r!r"r#rr)r	r	r	r
r$Ns
r$N)�	functoolsr�testfixturesrr"�objectrr$r	r	r	r
�<module>s1