o
    Gï÷_a  ã                   @   s\   d Z ddlmZ ddlmZ ddlmZ G dd„ deƒZG dd	„ d	eƒZ	G d
d„ deƒZ
dS )z!
Tests for hyperlink.test.common
é    )ÚAny)ÚTestCaseé   )ÚHyperlinkTestCasec                   @   ó   e Zd ZdZdS )Ú_ExpectedExceptionú9An exception used to test HyperlinkTestCase.assertRaises.N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú</usr/lib/python3/dist-packages/hyperlink/test/test_common.pyr   	   ó    r   c                   @   r   )Ú_UnexpectedExceptionr   Nr	   r   r   r   r   r      r   r   c                   @   sH   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dS )ÚTestHyperlinkzTests for HyperlinkTestCasec                 C   s   t dƒ| _d S )NÚrun)r   Úhyperlink_test©Úselfr   r   r   ÚsetUp   s   zTestHyperlink.setUpc                    s>   g ‰ ‡ fdd„}| j jt|ddd� |  ˆ dddifg¡ dS )	z½HyperlinkTestCase.assertRaises does not raise an AssertionError
        when given a callable that, when called with the provided
        arguments, raises the expected exception.

        c                     s   ˆ   | |f¡ t‚©N)Úappendr   ©ÚargsÚkwargs©Úcalled_withr   r   ÚraisesExpected!   s   zCTestHyperlink.test_assertRaisesWithCallable.<locals>.raisesExpectedr   T)Úkeyword)r   r    N)r   ÚassertRaisesr   ÚassertEqual)r   r   r   r   r   Útest_assertRaisesWithCallable   s   ÿz+TestHyperlink.test_assertRaisesWithCallablec                 C   ó2   dd„ }z
| j  t|¡ W dS  ty   Y dS w )z‚When given a callable that raises an unexpected exception,
        HyperlinkTestCase.assertRaises raises that exception.

        c                  _   s   t ‚r   )r   r   r   r   r   ÚdoesNotRaiseExpected2   ó   z\TestHyperlink.test_assertRaisesWithCallableUnexpectedException.<locals>.doesNotRaiseExpectedN©r   r!   r   r   )r   r%   r   r   r   Ú0test_assertRaisesWithCallableUnexpectedException+   s   
ÿÿz>TestHyperlink.test_assertRaisesWithCallableUnexpectedExceptionc                 C   r$   )z�HyperlinkTestCase.assertRaises raises an AssertionError when given
        a callable that, when called, does not raise any exception.

        c                  _   s   d S r   r   r   r   r   r   ÚdoesNotRaiseD   r&   zMTestHyperlink.test_assertRaisesWithCallableDoesNotRaise.<locals>.doesNotRaiseN©r   r!   r   ÚAssertionError)r   r)   r   r   r   Ú)test_assertRaisesWithCallableDoesNotRaise=   s   ÿz7TestHyperlink.test_assertRaisesWithCallableDoesNotRaisec                 C   s8   | j  t¡�}t‚1 sw   Y  |  t|jtƒ¡ dS )a  HyperlinkTestCase.assertRaises does not raise an AssertionError
        when used as a context manager with a suite that raises the
        expected exception.  The context manager stores the exception
        instance under its `exception` instance variable.

        N)r   r!   r   Ú
assertTrueÚ
isinstanceÚ	exception)r   Úcmr   r   r   Útest_assertRaisesContextManagerM   s   ÿ
ÿz-TestHyperlink.test_assertRaisesContextManagerc                 C   s>   z| j  t¡� t‚1 sw   Y  W dS  ty   Y dS w )z«When used as a context manager with a block that raises an
        unexpected exception, HyperlinkTestCase.assertRaises raises
        that unexpected exception.

        Nr'   r   r   r   r   Ú2test_assertRaisesContextManagerUnexpectedException\   s   ÿÿz@TestHyperlink.test_assertRaisesContextManagerUnexpectedExceptionc                 C   sL   z| j  t¡�
 W d  ƒ W dS 1 sw   Y  W dS  ty%   Y dS w )z HyperlinkTestcase.assertRaises raises an AssertionError when used
        as a context manager with a block that does not raise any
        exception.

        Nr*   r   r   r   r   Ú+test_assertRaisesContextManagerDoesNotRaisei   s   &ÿÿz9TestHyperlink.test_assertRaisesContextManagerDoesNotRaiseN)r
   r   r   r   r   r#   r(   r,   r1   r2   r3   r   r   r   r   r      s    r   N)r   Útypingr   Úunittestr   Úcommonr   Ú	Exceptionr   r   r   r   r   r   r   Ú<module>   s    