summaryrefslogtreecommitdiff
path: root/src/zope/component/testlayer.py
diff options
context:
space:
mode:
authorMichael Howitz <mh@gocept.com>2023-04-14 08:03:36 +0200
committerGitHub <noreply@github.com>2023-04-14 08:03:36 +0200
commit1c6af940c08ca2fdb142916974a192ab6ff9ea7c (patch)
tree924adcafcaf497f1fa5f4c2f506ff6085caa3ae6 /src/zope/component/testlayer.py
parentba0550c4645c3e73f32f7cd77bbe3cc528f76ad6 (diff)
downloadzope-component-1c6af940c08ca2fdb142916974a192ab6ff9ea7c.tar.gz
Config with pure python template (#71)
* Lint the code, improve coverage. * Bumped version for breaking release. * Drop support for Python 2.7, 3.5, 3.6.
Diffstat (limited to 'src/zope/component/testlayer.py')
-rw-r--r--src/zope/component/testlayer.py20
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)