
    G_	                     T    d dl mZmZmZmZ d dlmZ  G d de      Z G d de      Z	y)    )AnyCallableOptionalType)TestCasec                       e Zd ZdZ	 ddZy)HyperlinkTestCaseznThis type mostly exists to provide a backwards-compatible
    assertRaises method for Python 2.6 testing.
    Nc                 b    t        ||       }||S |5   ||i | ddd       y# 1 sw Y   yxY w)a  Fail unless an exception of class expected_exception is raised
        by callableObj when invoked with arguments args and keyword
        arguments kwargs. If a different type of exception is
        raised, it will not be caught, and the test case will be
        deemed to have suffered an error, exactly as for an
        unexpected exception.

        If called with callableObj omitted or None, will return a
        context object used like this::

             with self.assertRaises(SomeException):
                 do_something()

        The context manager keeps a reference to the exception as
        the 'exception' attribute. This allows you to inspect the
        exception after the assertion::

            with self.assertRaises(SomeException) as cm:
                do_something()
            the_exception = cm.exception
            self.assertEqual(the_exception.error_code, 3)
        N)_AssertRaisesContext)selfexpected_exceptioncallableObjargskwargscontexts         7/usr/lib/python3/dist-packages/hyperlink/test/common.pyassertRaiseszHyperlinkTestCase.assertRaises
   sA    < ''94@N 	)((	) 	) 	)s   	%.N)__name__
__module____qualname____doc__r        r   r	   r	      s     ")r   r	   c                   "    e Zd ZdZd Zd Zd Zy)r   zCA context manager used to implement HyperlinkTestCase.assertRaises.c                 4    || _         |j                  | _        y r   )expectedfailureException)r   r   	test_cases      r   __init__z_AssertRaisesContext.__init__2   s      ) : :r   c                     | S r   r   )r   s    r   	__enter__z_AssertRaisesContext.__enter__7   s    r   c                     |*| j                   j                  }| j                  |d      t        || j                         sy|| _        y)Nz not raisedFT)r   r   r   
issubclass	exception)r   exc_type	exc_valuetbexc_names        r   __exit__z_AssertRaisesContext.__exit__;   sF    }}--H''8(EFF(DMM2"r   N)r   r   r   r   r    r"   r*   r   r   r   r   r   /   s    I;
	r   r   N)
typingr   r   r   r   unittestr   r	   objectr   r   r   r   <module>r.      s'    0 0 ') ')T6 r   