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 )NzˆAn 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Ú	candidatez•The 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   )Nz‚An 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!   z�The 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!   zŒThe 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!   z„The 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 exceptionz´The 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Ú	exceptionz°MultipleInvalid(<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