File: //proc/1233/cwd/lib/python3/dist-packages/zope/interface/tests/__pycache__/__init__.cpython-310.pyc
o
$
x`� � @ sl d dl mZ G dd� de�ZG dd� de�Zzd dlmZ W n ey0 G dd� de�ZY d S w ejZd S )
� )�_should_attempt_c_optimizationsc @ s( e Zd ZdZdd� Zdd� Zdd� ZdS ) �OptimizationTestMixinzP
Helper for testing that C optimizations are used
when appropriate.
c C � t �)zq
Define this to return the implementation in use,
without the 'Py' or 'Fallback' suffix.
��NotImplementedError��self� r �?/usr/lib/python3/dist-packages/zope/interface/tests/__init__.py�_getTargetClass
s z%OptimizationTestMixin._getTargetClassc C r )zK
Define this to return the fallback Python implementation.
r r r r r
�_getFallbackClass s z'OptimizationTestMixin._getFallbackClassc C s6 | � � }| �� }t� r| �||� d S | �||� d S �N)r r r �assertIsNot�assertIs)r �used�fallbackr r r
�test_optimizations s
z(OptimizationTestMixin.test_optimizationsN)�__name__�
__module__�__qualname__�__doc__r r r r r r r
r s
r c @ s8 e Zd ZdZdd� Zdd� Zeeee fZ
edd� �ZdS ) �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 K s || _ t�| d�}|�|� d S )N�__dict__)�_MissingSomeAttrs__exc_kind�object�__getattribute__�update)r �exc_kind�other_attrs�dr r r
�__init__- s zMissingSomeAttrs.__init__c C s2 t �| d�}z|| W S ty |d |��w )Nr r )r r �KeyError)r �namer r r r
r 2 s
�z!MissingSomeAttrs.__getattribute__c
K s� t |t�sJ �||vs
J �| jD ]-}| |fi |��}|�|��}||� W d � n1 s.w Y |�|jjd |� q| tfi |��}z||� W dS tyh } z|�|t|�� W Y d}~dS d}~w t yq Y dS 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�er r r
�test_raisesA s"