
    Vh-                         d Z ddlZd Z G d dej                        Z G d dej                        Zd Z G d	 d
ej                        Z G d dej                        Zy)z& zope.interface.exceptions unit tests
    Nc                  (    ddl m}   G d d|       }|S )Nr   )	Interfacec                       e Zd Zy)_makeIface.<locals>.IDummyN)__name__
__module____qualname__     T/home/dcms/DCMS/lib/python3.12/site-packages/zope/interface/tests/test_exceptions.pyIDummyr      s    r   r   )zope.interfacer   )r   r   s     r   
_makeIfacer      s    (  Mr   c                   $    e Zd Zd Zd Zd Zd Zy)DoesNotImplementTestsc                     ddl m} |S )Nr   )DoesNotImplement)zope.interface.exceptionsr   )selfr   s     r   _getTargetClassz%DoesNotImplementTests._getTargetClass   s    >r   c                 D    t               } | j                         |g| S )Nr   r   r   argsifaces      r   _makeOnezDoesNotImplementTests._makeOne"   s$    %t##%e3d33r   c                 Z    | j                         }| j                  t        |      d       y )NzAn object has failed to implement interface zope.interface.tests.test_exceptions.IDummy: Does not declaratively implement the interface.r   assertEqualstrr   dnis     r   test___str__z"DoesNotImplementTests.test___str__&   s'    mmoH>	
r   c                 \    | j                  d      }| j                  t        |      d       y )N	candidatezThe object 'candidate' has failed to implement interface zope.interface.tests.test_exceptions.IDummy: Does not declaratively implement the interface.r   r!   s     r   test___str__w_candidatez-DoesNotImplementTests.test___str__w_candidate/   s*    mmK(H>	
r   Nr   r   r	   r   r   r#   r&   r
   r   r   r   r      s     4

r   r   c                   $    e Zd Zd Zd Zd Zd Zy)BrokenImplementationTestsc                     ddl m} |S )Nr   )BrokenImplementation)r   r+   )r   r+   s     r   r   z)BrokenImplementationTests._getTargetClass;   s    B##r   c                 F    t               } | j                         |dg| S )Nmissingr   r   s      r   r   z"BrokenImplementationTests._makeOne?   s&    %t##%eY>>>r   c                 Z    | j                         }| j                  t        |      d       y )NzAn object has failed to implement interface zope.interface.tests.test_exceptions.IDummy: The 'missing' attribute was not provided.r   r!   s     r   r#   z&BrokenImplementationTests.test___str__C   s'    mmoH8	9r   c                 \    | j                  d      }| j                  t        |      d       y )Nr%   zThe object 'candidate' has failed to implement interface zope.interface.tests.test_exceptions.IDummy: The 'missing' attribute was not provided.r   r!   s     r   r&   z1BrokenImplementationTests.test___str__w_candidateK   s*    mmK(H8	9r   Nr'   r
   r   r   r)   r)   9   s    $?99r   r)   c                       y)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   broken_functionr1   T   s    r   c                   :    e Zd Zd ZdZd Zd Zd Zd Zd Z	d Z
y	)
BrokenMethodImplementationTestsc                     ddl m} |S )Nr   BrokenMethodImplementation)r   r6   )r   r6   s     r   r   z/BrokenMethodImplementationTests._getTargetClass_   s    H))r   	I said soc                 F     | j                         d| j                  g| S )NaMethod)r   message)r   r   s     r   r   z(BrokenMethodImplementationTests._makeOnee   s#    %t##%iEEEr   c                 Z    | j                         }| j                  t        |      d       y )NzoAn object has failed to implement interface <Unknown>: The contract of 'aMethod' is violated because I said so.r   r!   s     r   r#   z,BrokenMethodImplementationTests.test___str__h   s(    mmoHG	
r   c                 `    | j                  ddd      }| j                  t        |      d       y )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!   s     r   )test___str__w_candidate_no_implementationzIBrokenMethodImplementationTests.test___str__w_candidate_no_implementationp   s/    mmOX{CHG	
r   c                 v    d| _         | j                  t        dd      }| j                  t	        |      d       y )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   r1   r   r    r!   s     r   (test___str__w_candidate_w_implementationzHBrokenMethodImplementationTests.test___str__w_candidate_w_implementationx   s5    0mmOX{CH,	
r   c                 n    d| _         | j                  ddd      }| j                  t        |      d       y )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!   s     r   5test___str__w_candidate_w_implementation_not_callablezUBrokenMethodImplementationTests.test___str__w_candidate_w_implementation_not_callable   s5    7mmB+6H$	
r   c                 ^    | j                  d d      }| j                  t        |      d       y )Nr%   zEBrokenMethodImplementation('aMethod', 'I said so', None, 'candidate'))r   r   reprr!   s     r   test___repr__w_candidatez8BrokenMethodImplementationTests.test___repr__w_candidate   s,    mmD+.I9	
r   N)r   r   r	   r   r:   r   r#   r?   rA   rD   rG   r
   r   r   r3   r3   ]   s-    * GF




r   r3   c                   $    e Zd Zd Zd Zd Zd Zy)MultipleInvalidTestsc                     ddl m} |S )Nr   )MultipleInvalid)r   rK   )r   rK   s     r   r   z$MultipleInvalidTests._getTargetClass   s    =r   c                 F    t               } | j                         |d|      S )Ntargetr   )r   excsr   s      r   r   zMultipleInvalidTests._makeOne   s#    %t##%eXt<<r   c                     ddl m}  |dd      t        d      g}| j                  |      }| j	                  t        |      d       y )Nr   r5   r9   r7   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   r6   	Exceptionr   r   r    r   r6   rN   r"   s       r   test__str__z MultipleInvalidTests.test__str__   sI    H&y+>)*
 mmD!H$	
r   c                     ddl m}  |dd      t        dd      g}| j                  |      }| j	                  t        |      d       y )Nr   r5   r9   r7   Regular	exceptionzMultipleInvalid(<InterfaceClass zope.interface.tests.test_exceptions.IDummy>, 'target', (BrokenMethodImplementation('aMethod', 'I said so'), Exception('Regular', 'exception'))))r   r6   rP   r   r   rF   rQ   s       r   test__repr__z!MultipleInvalidTests.test__repr__   sL    H&y+> i-	
 mmD!I3	
r   N)r   r   r	   r   r   rR   rV   r
   r   r   rI   rI      s    =

r   rI   )	__doc__unittestr   TestCaser   r)   r1   r3   rI   r
   r   r   <module>rZ      s`    
H-- 
:9 1 1 965
h&7&7 5
p)
8,, )
r   