U
     UYG                     @   sP   d 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
    )TestCase   )HyperlinkTestCasec                   @   s   e Zd ZdZdS )_ExpectedException?An exception used to test HyperlinkTestCase.assertRaises.

    N__name__
__module____qualname____doc__ r   r   </usr/lib/python3/dist-packages/hyperlink/test/test_common.pyr      s   r   c                   @   s   e Zd ZdZdS )_UnexpectedExceptionr   Nr   r   r   r   r   r      s   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 )	zHyperlinkTestCase.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d S N)appendr   argskwargsZcalled_withr   r   raisesExpected"   s    zCTestHyperlink.test_assertRaisesWithCallable.<locals>.raisesExpectedr   T)keyword)r   r   N)r   assertRaisesr   ZassertEqual)r   r   r   r   r   test_assertRaisesWithCallable   s      z+TestHyperlink.test_assertRaisesWithCallablec                 C   s4   dd }z| j t| W n tk
r.   Y nX dS )zWhen given a callable that raises an unexpected exception,
        HyperlinkTestCase.assertRaises raises that exception.

        c                  _   s   t d S r   )r   r   r   r   r   doesNotRaiseExpected0   s    z\TestHyperlink.test_assertRaisesWithCallableUnexpectedException.<locals>.doesNotRaiseExpectedNr   r   r   r   )r   r   r   r   r   0test_assertRaisesWithCallableUnexpectedException*   s    z>TestHyperlink.test_assertRaisesWithCallableUnexpectedExceptionc                 C   s4   dd }z| j t| W n tk
r.   Y nX dS )zHyperlinkTestCase.assertRaises raises an AssertionError when given
        a callable that, when called, does not raise any exception.

        c                  _   s   dS )NTr   r   r   r   r   doesNotRaise?   s    zMTestHyperlink.test_assertRaisesWithCallableDoesNotRaise.<locals>.doesNotRaiseNr   r   r   AssertionError)r   r"   r   r   r   )test_assertRaisesWithCallableDoesNotRaise9   s    z7TestHyperlink.test_assertRaisesWithCallableDoesNotRaisec              	   C   s2   | j t
}tW 5 Q R X | 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   Z
assertTrue
isinstanceZ	exception)r   cmr   r   r   test_assertRaisesContextManagerH   s    z-TestHyperlink.test_assertRaisesContextManagerc              	   C   s:   z | j t
 tW 5 Q R X W n tk
r4   Y nX dS )zWhen 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_assertRaisesContextManagerUnexpectedExceptionT   s
    z@TestHyperlink.test_assertRaisesContextManagerUnexpectedExceptionc              	   C   s6   z| j t W 5 Q R X W n tk
r0   Y nX dS )zHyperlinkTestcase.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_assertRaisesContextManagerDoesNotRaise`   s
    z9TestHyperlink.test_assertRaisesContextManagerDoesNotRaiseN)r   r	   r
   r   r   r   r!   r%   r(   r)   r*   r   r   r   r   r      s   r   N)	r   Zunittestr   commonr   	Exceptionr   r   r   r   r   r   r   <module>   s
   