U
    [e'                     @   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/var/www/html/services/stratfitenv/lib/python3.8/site-packages/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 )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__"   s
    z"DoesNotImplementTests.test___str__c                 C   s   |  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+   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   7   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 )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   ?   s
    z&BrokenImplementationTests.test___str__c                 C   s   |  d}| t|d d S )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   s
    
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   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   a   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   d   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_implementationl   s
    zIBrokenMethodImplementationTests.test___str__w_candidate_no_implementationc                 C   s(   d| _ | tdd}| t|d d S )Nzimplementation is wonkyr'   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   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   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~   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!   Y   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 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#   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	exceptionzMultipleInvalid(<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   	7