ok

Mini Shell

Direktori : /lib/python3.6/site-packages/zope/component/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/zope/component/__pycache__/testlayer.cpython-36.pyc

3

,�WX�@s�ddlZddlmZmZyddlmZWnek
rDdd�ZYnXddlmZddl	m
Z
ddlmZm
Z
Gd	d
�d
e�ZGdd�de�ZGd
d�de�ZdS)�N)�	xmlconfig�config)�cleanUpcCsdS)N�rrr�/usr/lib/python3.6/testlayer.pyrsr)�provideHandler)�setHooks)�events�clearEventsc@s>eZdZdZfZd
dd�Zdd�Zdd�Zd	d
�Zdd�Z	dS)�	LayerBasea�Sane layer base class.

    zope.testing implements an advanced mechanism so that layer setUp,
    tearDown, testSetUp and testTearDown code gets called in the right
    order. These methods are supposed to be @classmethods and should
    not use super() as the test runner is supposed to take care of that.

    In practice, this mechanism turns out not to be useful and
    overcomplicated.  It becomes difficult to pass information into
    layers (such as a ZCML file to load), because the only way to pass
    in information is to subclass, and subclassing these layers leads
    to a range of interactions that is hard to reason about.

    We'd rather just use Python and the super mechanism, as we know how
    to reason about that. This base class is a hack to make this
    possible.

    The hack requires us to set __bases__, __module__ and
    __name__. This fools zope.testing into thinking that this layer
    instance is a class it can work with.

    It'd be better if zope.testing just called a minimal API and
    didn't try to be fancy. Fancy layer inheritance mechanisms can
    then be implemented elsewhere if people want to. But unfortunately
    it does implement a fancy mechanism and we need to fool it.
    NcCs(|dkr|jj}||_|j|_||_dS)N)�	__class__�__name__�
__module__�package)�selfr�namerrr�__init__;s
zLayerBase.__init__cCsdS)Nr)rrrr�setUpBszLayerBase.setUpcCsdS)Nr)rrrr�tearDownEszLayerBase.tearDowncCsdS)Nr)rrrr�	testSetUpHszLayerBase.testSetUpcCsdS)Nr)rrrr�testTearDownKszLayerBase.testTearDown)N)
r
r�__qualname__�__doc__�	__bases__rrrrrrrrrrs
rcsBeZdZdZd
�fdd�	Zdd�Zdd�Zd	d
�Zdd�Z�Z	S)�
ZCMLLayerBasez%Base class to load up some ZCML.
    Ncs tt|�j||�|pg|_dS)N)�superrr�features)rrrr)rrrrQszZCMLLayerBase.__init__cCsNt�tj�}tj|�x|jD]}|j|�q W|j|�|_t	t
jd�dS)N)N)rrZConfigurationMachinerZregisterCommonDirectivesrZprovideFeature�
_load_zcml�contextrr	�append)rrZfeaturerrrrUs
zZCMLLayerBase.setUpcCs
t�dS)N)r
)rrrrr^szZCMLLayerBase.testTearDowncCs
t�dS)N)r)rrrrraszZCMLLayerBase.tearDowncCst�dS)N)�NotImplementedError)rrrrrrdszZCMLLayerBase._load_zcml)NN)
r
rrrrrrrr�
__classcell__rr)rrrNs	rcs*eZdZdZd�fdd�	Zdd�Z�ZS)	�
ZCMLFileLayera8This layer can be used to run tests with a ZCML file loaded.

    The ZCML file is assumed to include sufficient (meta)configuration
    so that it can be interpreted itself. I.e. to create a ZCMLLayer
    based on another ZCMLLayer's ZCML, just use a ZCML include
    statement in your own ZCML to load it.
    �
ftesting.zcmlNcs2tt|�j|||�tjjtjj|j�|�|_dS)N)	rr"r�os�path�join�dirname�__file__�	zcml_file)rrr)rr)rrrroszZCMLFileLayer.__init__cCstj|j|j|dd�S)NT)rrZexecute)r�filer)r)rrrrrruszZCMLFileLayer._load_zcml)r#NN)r
rrrrrr!rr)rrr"gsr")r$Zzope.configurationrrZzope.testing.cleanupr�ImportErrorZzope.componentrZzope.component.hooksrZzope.component.eventtestingr	r
�objectrrr"rrrr�<module>s1

Zerion Mini Shell 1.0