o
    Êó·i   ã                   @   s„   d Z ddlZddlZG dd„ dejjƒ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                   @   s   e Zd ZdS )ÚIDummyN)Ú__name__Ú
__module__Ú__qualname__© r   r   újC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\zope/interface/tests/test_exceptions.pyr      s    r   c                  C   s   ddl m}  | S )Nr   ©r   )Z$zope.interface.tests.test_exceptionsr   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_candidate2   ó
   
þ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   >   r   z)BrokenImplementationTests._getTargetClassc                 G   s   t ƒ }|  ¡ |dg|¢R Ž S )NÚmissingr   r   r   r   r   r   B   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   F   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!   N   r"   z1BrokenImplementationTests.test___str__w_candidateNr#   r   r   r   r   r$   <   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_functionW   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   b   r   z/BrokenMethodImplementationTests._getTargetClassú	I said soc                 G   s   |   ¡ d| jg|¢R Ž S )NÚaMethod)r   Úmessage)r   r   r   r   r   r   h   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   k   r   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_implementations   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_implementation{   ó   þ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…   r1   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/   r0   r3   r5   r   r   r   r   r(   `   s    

r(   c                   @   r
   )
ÚMultipleInvalidTestsc                 C   r   )Nr   )ÚMultipleInvalid)r   r7   )r   r7   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*   r9   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*   r:   r   r   r4   r;   r   r   r   Útest__repr__±   s   ü
þz!MultipleInvalidTests.test__repr__N)r   r   r   r   r   r<   r>   r   r   r   r   r6   ˜   s
    r6   )Ú__doc__ZunittestZzope.interfaceZzopeZ	interfaceZ	Interfacer   r	   ZTestCaser   r$   r'   r(   r6   r   r   r   r   Ú<module>   s   	8