[Checkins] SVN: z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layer.py Add a ZCML layer definition.

Uli Fouquet uli at gnufix.de
Mon Jul 28 10:46:57 EDT 2008


Log message for revision 88867:
  Add a ZCML layer definition.

Changed:
  U   z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layer.py

-=-
Modified: z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layer.py
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layer.py	2008-07-28 14:46:31 UTC (rev 88866)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layer.py	2008-07-28 14:46:55 UTC (rev 88867)
@@ -1,6 +1,30 @@
+"""Layer definitions.
 
-layer_marker = None
+This could also be done in the setup file itself.
+"""
 
+import os
+from zope.app.testing.functional import ZCMLLayer
+
+# We define a ZCML test layer. ZCML layers are special as they define
+# some setup code for creation of empty ZODBs and more. If you only
+# want some ZCML registrations to be done, you can use it like so:
+FunctionalLayer1 = ZCMLLayer(
+    # As first argument we need the absolute path of a ZCML file
+    os.path.join(os.path.dirname(__file__), 'ftesting.zcml'),
+
+    # Second argument is the module, where the layer is defined.
+    __name__,
+
+    # This is the name of our layer. It can be an arbitrary string.
+    'FunctionalLayer1',
+
+    # By default ZCML layers are not torn down. You should make sure,
+    # that any registrations you do in your ZCML are removed in a
+    # tearDown method if you specify this parameter to be `True`. This
+    # parameter is optional.
+    allow_teardown = True)
+
 class UnitLayer1(object):
     """This represents a layer.
     A layer is a way to have common setup and teardown that happens 



More information about the Checkins mailing list