diff options
Diffstat (limited to 'src/zope/component/testlayer.py')
| -rw-r--r-- | src/zope/component/testlayer.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/zope/component/testlayer.py b/src/zope/component/testlayer.py index f9d16ea..84ef2f1 100644 --- a/src/zope/component/testlayer.py +++ b/src/zope/component/testlayer.py @@ -14,19 +14,23 @@ import os -from zope.configuration import xmlconfig, config +from zope.configuration import config +from zope.configuration import xmlconfig + + try: from zope.testing.cleanup import cleanUp -except ImportError: # pragma: no cover +except ImportError: # pragma: no cover def cleanUp(): pass from zope.component import provideHandler +from zope.component.eventtesting import clearEvents +from zope.component.eventtesting import events from zope.component.hooks import setHooks -from zope.component.eventtesting import events, clearEvents -class LayerBase(object): +class LayerBase: """Sane layer base class. zope.testing implements an advanced mechanism so that layer setUp, @@ -75,11 +79,13 @@ class LayerBase(object): def testTearDown(self): pass + class ZCMLLayerBase(LayerBase): """Base class to load up some ZCML. """ + def __init__(self, package, name=None, features=None): - super(ZCMLLayerBase, self).__init__(package, name) + super().__init__(package, name) self.features = features or [] def setUp(self): @@ -100,6 +106,7 @@ class ZCMLLayerBase(LayerBase): def _load_zcml(self, context): raise NotImplementedError + class ZCMLFileLayer(ZCMLLayerBase): """This layer can be used to run tests with a ZCML file loaded. @@ -108,9 +115,10 @@ class ZCMLFileLayer(ZCMLLayerBase): based on another ZCMLLayer's ZCML, just use a ZCML include statement in your own ZCML to load it. """ + def __init__(self, package, zcml_file='ftesting.zcml', name=None, features=None): - super(ZCMLFileLayer, self).__init__(package, name, features) + super().__init__(package, name, features) self.zcml_file = os.path.join(os.path.dirname(package.__file__), zcml_file) |
