o
    $x`'                     @   sh   d Z ddlZdd ZG dd dejZG dd dejZd	d
 ZG dd dejZG dd dejZdS )z& zope.interface.exceptions unit tests
    Nc                  C   s    ddl m}  G dd d| }|S )Nr   )	Interfacec                   @   s   e Zd ZdS )z_makeIface.<locals>.IDummyN)__name__
__module____qualname__ r   r   F/usr/lib/python3/dist-packages/zope/interface/tests/test_exceptions.pyIDummy   s    r   )zope.interfacer   )r   r   r   r   r   
_makeIface   s   r
   c                   @   ,   e Zd Zdd Zdd Zdd Zdd Zd	S )
DoesNotImplementTestsc                 C      ddl m} |S )Nr   )DoesNotImplement)zope.interface.exceptionsr   )selfr   r   r   r   _getTargetClass      z%DoesNotImplementTests._getTargetClassc                 G   s   t  }|  |g|R  S )Nr
   r   r   argsifacer   r   r   _makeOne   s   zDoesNotImplementTests._makeOnec                 C      |   }| t|d d S )NzAn object has failed to implement interface zope.interface.tests.test_exceptions.IDummy: Does not declaratively implement the interface.r   assertEqualstrr   dnir   r   r   test___str__"   
   z"DoesNotImplementTests.test___str__c                 C      |  d}| t|d d S )N	candidatezThe object 'candidate' has failed to implement interface zope.interface.tests.test_exceptions.IDummy: Does not declaratively implement the interface.r   r   r   r   r   test___str__w_candidate+   
   
z-DoesNotImplementTests.test___str__w_candidateNr   r   r   r   r   r   r"   r   r   r   r   r      s
    	r   c                   @   r   )
BrokenImplementationTestsc                 C   r   )Nr   )BrokenImplementation)r   r&   )r   r&   r   r   r   r   7   r   z)BrokenImplementationTests._getTargetClassc                 G   s   t  }|  |dg|R  S )Nmissingr   r   r   r   r   r   ;   s   z"BrokenImplementationTests._makeOnec                 C   r   )NzAn object has failed to implement interface zope.interface.tests.test_exceptions.IDummy: The 'missing' attribute was not provided.r   r   r   r   r   r   ?   r   z&BrokenImplementationTests.test___str__c                 C   r    )Nr!   zThe object 'candidate' has failed to implement interface zope.interface.tests.test_exceptions.IDummy: The 'missing' attribute was not provided.r   r   r   r   r   r"   G   r#   z1BrokenImplementationTests.test___str__w_candidateNr$   r   r   r   r   r%   5   s
    r%   c                   C   s   dS )z
    This is a global function with a simple argument list.

    It exists to be able to report the same information when
    formatting signatures under Python 2 and Python 3.
    Nr   r   r   r   r   broken_functionP   s    r(   c                   @   sH   e Zd Zdd ZdZdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dS )BrokenMethodImplementationTestsc                 C   r   )Nr   BrokenMethodImplementation)r   r+   )r   r+   r   r   r   r   [   r   z/BrokenMethodImplementationTests._getTargetClass	I said soc                 G   s   |   d| jg|R  S )NaMethod)r   message)r   r   r   r   r   r   a   s   z(BrokenMethodImplementationTests._makeOnec                 C   r   )NzoAn object has failed to implement interface <Unknown>: The contract of 'aMethod' is violated because I said so.r   r   r   r   r   r   d   r   z,BrokenMethodImplementationTests.test___str__c                 C   s"   |  ddd}| t|d d S )Nsome_function<IFoo>r!   zyThe object 'candidate' has failed to implement interface <IFoo>: The contract of 'aMethod' is violated because I said so.r   r   r   r   r   )test___str__w_candidate_no_implementationl   s
   zIBrokenMethodImplementationTests.test___str__w_candidate_no_implementationc                 C   s(   d| _ | tdd}| t|d d S )Nzimplementation is wonkyr0   r!   zThe object 'candidate' has failed to implement interface <IFoo>: The contract of 'aMethod' is violated because 'broken_function()' is wonky.)r.   r   r(   r   r   r   r   r   r   (test___str__w_candidate_w_implementationt      zHBrokenMethodImplementationTests.test___str__w_candidate_w_implementationc                 C   s(   d| _ | ddd}| t|d d S )Nzimplementation is not callable*   r0   r!   zThe object 'candidate' has failed to implement interface <IFoo>: The contract of 'aMethod' is violated because '42' is not callable.)r.   r   r   r   r   r   r   r   5test___str__w_candidate_w_implementation_not_callable~   r3   zUBrokenMethodImplementationTests.test___str__w_candidate_w_implementation_not_callablec                 C   s    |  d d}| t|d d S )Nr!   zEBrokenMethodImplementation('aMethod', 'I said so', None, 'candidate'))r   r   reprr   r   r   r   test___repr__w_candidate   s
   z8BrokenMethodImplementationTests.test___repr__w_candidateN)r   r   r   r   r.   r   r   r1   r2   r5   r7   r   r   r   r   r)   Y   s    

r)   c                   @   r   )
MultipleInvalidTestsc                 C   r   )Nr   )MultipleInvalid)r   r9   )r   r9   r   r   r   r      r   z$MultipleInvalidTests._getTargetClassc                 C   s   t  }|  |d|S )Ntargetr   )r   excsr   r   r   r   r      s   zMultipleInvalidTests._makeOnec                 C   s<   ddl m} |ddtdg}| |}| t|d d S )Nr   r*   r-   r,   zRegular exceptionzThe object 'target' has failed to implement interface zope.interface.tests.test_exceptions.IDummy:
    The contract of 'aMethod' is violated because I said so
    Regular exception)r   r+   	Exceptionr   r   r   r   r+   r;   r   r   r   r   test__str__   s   
z MultipleInvalidTests.test__str__c                 C   s>   ddl m} |ddtddg}| |}| t|d d S )Nr   r*   r-   r,   Regular	exceptionzMultipleInvalid(<InterfaceClass zope.interface.tests.test_exceptions.IDummy>, 'target', (BrokenMethodImplementation('aMethod', 'I said so'), Exception('Regular', 'exception'))))r   r+   r<   r   r   r6   r=   r   r   r   test__repr__   s   
z!MultipleInvalidTests.test__repr__N)r   r   r   r   r   r>   rA   r   r   r   r   r8      s
    r8   )	__doc__unittestr
   TestCaser   r%   r(   r)   r8   r   r   r   r   <module>   s   	7