
    Vha                     n    d Z ddlmZ ddlmZ ddlmZ  G d de      Z G d d	e      Z	 G d
 de      Z
y)z!
Tests for hyperlink.test.common
    )Any)TestCase   )HyperlinkTestCasec                       e Zd ZdZy)_ExpectedException9An exception used to test HyperlinkTestCase.assertRaises.N__name__
__module____qualname____doc__     J/home/dcms/DCMS/lib/python3.12/site-packages/hyperlink/test/test_common.pyr   r   	       Cr   r   c                       e Zd ZdZy)_UnexpectedExceptionr	   Nr
   r   r   r   r   r      r   r   r   c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
TestHyperlinkzTests for HyperlinkTestCasec                 $    t        d      | _        y )Nrun)r   hyperlink_testselfs    r   setUpzTestHyperlink.setUp   s    /6r   c                     g fd}| j                   j                  t        |dd       | j                  dddifg       y)zHyperlinkTestCase.assertRaises does not raise an AssertionError
        when given a callable that, when called with the provided
        arguments, raises the expected exception.

        c                  6    j                  | |f       t        N)appendr   )argskwargscalled_withs     r   raisesExpectedzCTestHyperlink.test_assertRaisesWithCallable.<locals>.raisesExpected!   s    f~.$$r   r   T)keyword)r   r%   N)r   assertRaisesr   assertEqual)r   r$   r#   s     @r   test_assertRaisesWithCallablez+TestHyperlink.test_assertRaisesWithCallable   sR     	%
 	((4 	) 	
 	y$.?'@&ABr   c                 j    d }	 | j                   j                  t        |       y# t        $ r Y yw xY w)zWhen given a callable that raises an unexpected exception,
        HyperlinkTestCase.assertRaises raises that exception.

        c                      t         r   )r   r!   r"   s     r   doesNotRaiseExpectedz\TestHyperlink.test_assertRaisesWithCallableUnexpectedException.<locals>.doesNotRaiseExpected2   s    &&r   Nr   r&   r   r   )r   r,   s     r   0test_assertRaisesWithCallableUnexpectedExceptionz>TestHyperlink.test_assertRaisesWithCallableUnexpectedException+   s:    	'	,,"$8 $ 		    & 	22c                 j    d }	 | j                   j                  t        |       y# t        $ r Y yw xY w)zHyperlinkTestCase.assertRaises raises an AssertionError when given
        a callable that, when called, does not raise any exception.

        c                       y r   r   r+   s     r   doesNotRaisezMTestHyperlink.test_assertRaisesWithCallableDoesNotRaise.<locals>.doesNotRaiseD   s    r   Nr   r&   r   AssertionError)r   r2   s     r   )test_assertRaisesWithCallableDoesNotRaisez7TestHyperlink.test_assertRaisesWithCallableDoesNotRaise=   s5    		,,-?N 		r/   c                     | j                   j                  t              5 }t        # 1 sw Y   nxY w| j                  t	        j
                  t                     y)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   cms     r   test_assertRaisesContextManagerz-TestHyperlink.test_assertRaisesContextManagerM   sN       --.@A 	%R$$	% 	% 	r||%78	
s   '0c                     	 | j                   j                  t              5  t        # 1 sw Y   yxY w# t        $ r Y yw xY w)zWhen used as a context manager with a block that raises an
        unexpected exception, HyperlinkTestCase.assertRaises raises
        that unexpected exception.

        Nr-   r   s    r   2test_assertRaisesContextManagerUnexpectedExceptionz@TestHyperlink.test_assertRaisesContextManagerUnexpectedException\   sC    	$$112DE +**+ +# 		s   4 (14 4 	A A c                     	 | j                   j                  t              5  	 ddd       y# 1 sw Y   yxY w# t        $ r Y yw xY w)zHyperlinkTestcase.assertRaises raises an AssertionError when used
        as a context manager with a block that does not raise any
        exception.

        Nr3   r   s    r   +test_assertRaisesContextManagerDoesNotRaisez9TestHyperlink.test_assertRaisesContextManagerDoesNotRaisei   sE    	$$112DE    		s#   8 ,8 58 8 	AAN)r   r   r   r   r   r(   r.   r5   r;   r=   r?   r   r   r   r   r      s)    %7C&$ 
r   r   N)r   typingr   unittestr   commonr   	Exceptionr   r   r   r   r   r   <module>rD      s?      %D DD9 DcH cr   