
    Of                         d dl mZ  G d d          Z G d d          Z G d d          Z	 d dlmZ ej        ZdS # e$ r  G d	 d
          ZY dS w xY w)    )_should_attempt_c_optimizationsc                   $    e Zd ZdZd Zd Zd ZdS )OptimizationTestMixinzBMixin testing that C optimizations are used when appropriate.
    c                     t           )zMReturn the implementation in use, without 'Py' or 'Fallback' suffix.
        NotImplementedErrorselfs    O/var/www/html/env/lib/python3.11/site-packages/zope/interface/tests/__init__.py_getTargetClassz%OptimizationTestMixin._getTargetClass   
     "!    c                     t           )z3Return the fallback Python implementation.
        r   r	   s    r   _getFallbackClassz'OptimizationTestMixin._getFallbackClass   s
     "!r   c                     |                                  }|                                 }t                      r|                     ||           d S |                     ||           d S N)r   r   r   assertIsNotassertIs)r
   usedfallbacks      r   test_optimizationsz(OptimizationTestMixin.test_optimizations   sh    ##%%))++*,, 	*T8,,,,,MM$)))))r   N)__name__
__module____qualname____doc__r   r   r    r   r   r   r      sK         " " "
" " "* * * * *r   r   c                       e Zd Zd Zd ZdS )SubclassableMixinc                     t           )zLReturn the implementation in use without 'Py' or 'Fallback' suffix.
        r   r	   s    r   r   z!SubclassableMixin._getTargetClass!   r   r   c                 J    |                                  } G d d|          }d S )Nc                       e Zd ZdS )4SubclassableMixin.test_can_subclass.<locals>.DerivedN)r   r   r   r   r   r   Derivedr"   )   s        Dr   r#   )r   )r
   klassr#   s      r   test_can_subclassz#SubclassableMixin.test_can_subclass&   sG    $$&&	 	 	 	 	e 	 	 	 	 	r   N)r   r   r   r   r%   r   r   r   r   r      s2        " " "
    r   r   c                   @    e Zd ZdZd Zd Zeeee	fZ
ed             ZdS )MissingSomeAttrsa  
    Helper for tests that raises a specific exception
    for attributes that are missing. This is usually not
    an AttributeError, and this object is used to test that
    those errors are not improperly caught and treated like
    an AttributeError.
    c                 t    || _         t                              | d          }|                    |           d S )N__dict__)_MissingSomeAttrs__exc_kindobject__getattribute__update)r
   exc_kindother_attrsds       r   __init__zMissingSomeAttrs.__init__6   s6    "##D*55	r   c                     t                               | d          }	 ||         S # t          $ r  |d         |          w xY w)Nr)   r*   )r+   r,   KeyError)r
   namer0   s      r   r,   z!MissingSomeAttrs.__getattribute__;   sV    ##D*55	9T7N 	9 	9 	92!124888	9s	   % Ac                    t          |t                    sJ ||vsJ | j        D ]i} | |fi |}|                    |          5 } ||           ddd           n# 1 swxY w Y   |                    |j        j        d         |           j | t          fi |}	  ||           dS # t          $ r.}|                    |t          |                     Y d}~dS d}~wt          $ r Y dS w xY w)a  
        Loop through various exceptions, calling *test_func* inside a
        ``assertRaises`` block.

        :param test_func: A callable of one argument, the instance of this
            class.
        :param str expected_missing: The attribute that should fail with the
            exception.  This is used to ensure that we're testing the path we
            think we are.
        :param other_attrs: Attributes that should be provided on the test
            object.  Must not contain *expected_missing*.
        Nr   )

isinstancestrEXCEPTION_CLASSESassertRaisesassertEqual	exceptionargsAttributeErrorassertNotIn	Exception)	clsunittest	test_funcexpected_missingr/   excobexes	            r   test_raiseszMissingSomeAttrs.test_raisesJ   s    *C00000{2222( 	I 	ICS((K((B&&s++ r	"                 !21!57GHHHH S//;//	IbMMMMM 	; 	; 	;  !13q66::::::::: 	 	 	DD	s0   AA!	$A!	B+ +
C/5#CC/.C/N)r   r   r   r   r1   r,   	TypeErrorRuntimeErrorBaseException
ValueErrorr8   classmethodrH   r   r   r   r'   r'   -   sm           
9 9 9 		   [  r   r'   )cleanupc                       e Zd Zd ZexZZdS )CleanUpc                     d S r   r   r	   s    r   cleanUpzCleanUp.cleanUp}   s    Dr   N)r   r   r   rR   setUptearDownr   r   r   rP   rP   |   s)        	 	 	 #"r   rP   N)	zope.interface._compatr   r   r   r'   zope.testingrN   rP   ImportErrorr   r   r   <module>rX      s   B B B B B B* * * * * * * *6       < < < < < < < <V
$$$$$$ oGGG  # # ## # # # # # # # # # ##s   > AA