o
    Gï÷_Ã	  ã                   @   sH   d dl mZmZmZmZ d dlmZ G dd„ deƒZG dd„ deƒZ	dS )é    )ÚAnyÚCallableÚOptionalÚType)ÚTestCasec                   @   s   e Zd ZdZ	ddd„ZdS )ÚHyperlinkTestCaseznThis type mostly exists to provide a backwards-compatible
    assertRaises method for Python 2.6 testing.
    Nc                 O   sN   t || ƒ}|du r|S |� ||i |¤Ž W d  ƒ dS 1 s w   Y  dS )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Úcontext© r   ú7/usr/lib/python3/dist-packages/hyperlink/test/common.pyÚassertRaises
   s   
"ÿzHyperlinkTestCase.assertRaises©N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s    ýr   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	r   zCA context manager used to implement HyperlinkTestCase.assertRaises.c                 C   s   || _ |j| _d S r   )ÚexpectedÚfailureException)r	   r   Ú	test_caser   r   r   Ú__init__2   s   z_AssertRaisesContext.__init__c                 C   s   | S r   r   )r	   r   r   r   Ú	__enter__7   s   z_AssertRaisesContext.__enter__c                 C   s:   |d u r| j j}|  d|f ¡‚t|| j ƒsdS || _dS )Nz%s not raisedFT)r   r   r   Ú
issubclassÚ	exception)r	   Úexc_typeÚ	exc_valueÚtbÚexc_namer   r   r   Ú__exit__;   s   z_AssertRaisesContext.__exit__N)r   r   r   r   r   r   r"   r   r   r   r   r   /   s
    r   N)
Útypingr   r   r   r   Úunittestr   r   Úobjectr   r   r   r   r   Ú<module>   s    *