U
    P|j-  ã                   @   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   úH/tmp/pip-unpacked-wheel-zcalc2_b/zope/interface/tests/test_exceptions.pyÚIDummy   s   r   )Zzope.interfacer   )r   r   r   r   r   Ú
_makeIface   s    r	   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚDoesNotImplementTestsc                 C   s   ddl m} |S )Nr   )ÚDoesNotImplement)Úzope.interface.exceptionsr   )Úselfr   r   r   r   Ú_getTargetClass   s    z%DoesNotImplementTests._getTargetClassc                 G   s   t ƒ }|  ¡ |f|žŽ S )N©r	   r   ©r   ÚargsÚifacer   r   r   Ú_makeOne"   s    zDoesNotImplementTests._makeOnec                 C   s   |   ¡ }|  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__&   s
    þz"DoesNotImplementTests.test___str__c                 C   s   |   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/   s
    
þz-DoesNotImplementTests.test___str__w_candidateN©r   r   r   r   r   r   r   r   r   r   r   r
      s   	r
   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚBrokenImplementationTestsc                 C   s   ddl m} |S )Nr   )ÚBrokenImplementation)r   r   )r   r   r   r   r   r   ;   s    z)BrokenImplementationTests._getTargetClassc                 G   s   t ƒ }|  ¡ |df|žŽ S )NÚmissingr   r   r   r   r   r   ?   s    z"BrokenImplementationTests._makeOnec                 C   s   |   ¡ }|  t|ƒd¡ d S )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   C   s
    þz&BrokenImplementationTests.test___str__c                 C   s   |   d¡}|  t|ƒd¡ d S )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   K   s
    
þz1BrokenImplementationTests.test___str__w_candidateNr   r   r   r   r   r   9   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.
    Nr   r   r   r   r   Úbroken_functionT   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   s   ddl m} |S )Nr   ©ÚBrokenMethodImplementation)r   r#   )r   r#   r   r   r   r   _   s    z/BrokenMethodImplementationTests._getTargetClassú	I said soc                 G   s   |   ¡ d| jf|žŽ S )NÚaMethod)r   Úmessage)r   r   r   r   r   r   e   s    z(BrokenMethodImplementationTests._makeOnec                 C   s   |   ¡ }|  t|ƒd¡ d S )NzoAn object has failed to implement interface <Unknown>: The contract of 'aMethod' is violated because I said so.r   r   r   r   r   r   h   s
    þz,BrokenMethodImplementationTests.test___str__c                 C   s"   |   ddd¡}|  t|ƒd¡ d S )NZ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_implementationp   s
    þzIBrokenMethodImplementationTests.test___str__w_candidate_no_implementationc                 C   s(   d| _ |  tdd¡}|  t|ƒd¡ d S )Nzimplementation is wonkyr'   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_implementationx   s    þzHBrokenMethodImplementationTests.test___str__w_candidate_w_implementationc                 C   s(   d| _ |  ddd¡}|  t|ƒd¡ d S )Nzimplementation is not callableé*   r'   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‚   s    þ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   r(   r)   r+   r-   r   r   r   r   r!   ]   s   

r!   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚMultipleInvalidTestsc                 C   s   ddl m} |S )Nr   )ÚMultipleInvalid)r   r/   )r   r/   r   r   r   r   —   s    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#   r1   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$   ZRegularÚ	exceptionz°MultipleInvalid(<InterfaceClass zope.interface.tests.test_exceptions.IDummy>, 'target', (BrokenMethodImplementation('aMethod', 'I said so'), Exception('Regular', 'exception'))))r   r#   r2   r   r   r,   r3   r   r   r   Útest__repr__®   s    ü
þz!MultipleInvalidTests.test__repr__N)r   r   r   r   r   r4   r6   r   r   r   r   r.   •   s   r.   )	Ú__doc__Zunittestr	   ZTestCaser
   r   r    r!   r.   r   r   r   r   Ú<module>   s   		8