HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/hamcrest/core/core/__pycache__/raises.cpython-38.pyc
U

�b�V�@svddlmZddlZddlZddlmZddlmZdZdZ	dZ
Gdd	�d	e�Zdd
d�ZGdd
�d
e
�Zdd�ZdS)�)�refN)�BaseMatcher)�is_callablezPer FagrellzCopyright 2013 hamcrest.orgzBSD, see License.txtc@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�RaisesNcCs||_||_d|_d|_dS�N)�pattern�expected�actual�function)�selfrr�r�;/usr/lib/python3/dist-packages/hamcrest/core/core/raises.py�__init__
szRaises.__init__cCs t|�sdSt|�|_|�|�S)NF)rrr
�_call_function�rr
rrr
�_matchess
zRaises._matchescCsrd|_z
|�Wn\tk
rlt��d|_t|j|j�rh|jdk	rbt�|jt	|j��dk	YSYdSYnXdS)N�TF)
r	�	Exception�sys�exc_info�
isinstancerr�re�search�strrrrr
rs

zRaises._call_functioncCs|�d|j�dS)NzExpected a callable raising %s)�append_textr)r�descriptionrrr
�describe_to'szRaises.describe_tocCs�t|�s|�d|�dS|jdkr(dn|��}|dks@||k	rXt|�|_|�|�sXdS|jdkrn|�d�nRt|j|j�r�|jdk	r�|�d|j�|�dt	|j��n|�dt
|j��dS)Nz%s is not callablezNo exception raised.zICorrect assertion type raised, but the expected pattern ("%s") not found.z
          message was: "%s"z%s was raised instead)rrr
rrr	rrrr�type)r�itemrr
rrr
�describe_mismatch*s


zRaises.describe_mismatch)N)�__name__�
__module__�__qualname__rrrrrrrrr
rs


rcCs
t||�S)a�Matches if the called function raised the expected exception.

    :param exception:  The class of the expected exception
    :param pattern:    Optional regular expression to match exception message.

    Expects the actual to be wrapped by using :py:func:`~hamcrest.core.core.raises.calling`,
    or a callable taking no arguments.
    Optional argument pattern should be a string containing a regular expression.  If provided,
    the string representation of the actual exception - e.g. `str(actual)` - must match pattern.

    Examples::

        assert_that(calling(int).with_args('q'), raises(TypeError))
        assert_that(calling(parse, broken_input), raises(ValueError))
    )r)Z	exceptionrrrr
�raises>sr#c@s$eZdZdd�Zdd�Zdd�ZdS)�DeferredCallablecCs||_t�|_i|_dSr)�func�tuple�args�kwargs)rr%rrr
rRszDeferredCallable.__init__cCs|j|j|j�Sr)r%r'r()rrrr
�__call__WszDeferredCallable.__call__cOs||_||_|Sr)r'r()rr'r(rrr
�	with_argsZszDeferredCallable.with_argsN)r r!r"rr)r*rrrr
r$Qsr$cCst|�S)a�Wrapper for function call that delays the actual execution so that
    :py:func:`~hamcrest.core.core.raises.raises` matcher can catch any thrown exception.

    :param func: The function or method to be called

    The arguments can be provided with a call to the `with_args` function on the returned
    object::

           calling(my_method).with_args(arguments, and_='keywords')
    )r$)r%rrr
�calling`sr+)N)�weakrefrrrZhamcrest.core.base_matcherrZhamcrest.core.compatr�
__author__Z
__copyright__Z__license__rr#�objectr$r+rrrr
�<module>s2