U
    ʑZ<                     @   s0   d dl mZ G dd deZG dd deZdS )    )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   s4   t || }|dkr|S | ||| W 5 Q R X dS )a  Fail unless an exception of class excClass 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)selfZexcClassZ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 N)expectedfailureException)r   r   Z	test_caser	   r	   r
   __init__+   s    z_AssertRaisesContext.__init__c                 C   s   | S r   r	   )r   r	   r	   r
   	__enter__/   s    z_AssertRaisesContext.__enter__c                 C   s:   |d kr | j j}| d|f t|| j s0dS || _dS )Nz%s not raisedFT)r   r   r   
issubclassZ	exception)r   exc_type	exc_valuetbZexc_namer	   r	   r
   __exit__2   s    z_AssertRaisesContext.__exit__N)r   r   r   r   r   r   r   r	   r	   r	   r
   r   (   s   r   N)Zunittestr   r   objectr   r	   r	   r	   r
   <module>   s   "