[Checkins] SVN: z3c.testsetup/trunk/src/z3c/testsetup/ Grab
package-local ftesting.zcml by default.
Uli Fouquet
uli at gnufix.de
Sat Feb 16 20:00:46 EST 2008
Log message for revision 83965:
Grab package-local ftesting.zcml by default.
Changed:
U z3c.testsetup/trunk/src/z3c/testsetup/doctesting.py
U z3c.testsetup/trunk/src/z3c/testsetup/functionaldoctestsetup.txt
A z3c.testsetup/trunk/src/z3c/testsetup/tests/cave_to_let/
A z3c.testsetup/trunk/src/z3c/testsetup/tests/cave_to_let/__init__.py
A z3c.testsetup/trunk/src/z3c/testsetup/tests/cave_to_let/ftesting.zcml
-=-
Modified: z3c.testsetup/trunk/src/z3c/testsetup/doctesting.py
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/doctesting.py 2008-02-17 00:35:43 UTC (rev 83964)
+++ z3c.testsetup/trunk/src/z3c/testsetup/doctesting.py 2008-02-17 01:00:45 UTC (rev 83965)
@@ -143,6 +143,13 @@
zcml_config)
self.layer = ZCMLLayer(zcml_config, self.package.__name__,
layer_name)
+ elif layer is None:
+ # Look for ftesting.zcml in pkg-root...
+ pkg_ftesting_zcml = os.path.join(
+ os.path.dirname(self.package.__file__), 'ftesting.zcml')
+ if os.path.isfile(pkg_ftesting_zcml):
+ self.layer = ZCMLLayer(pkg_ftesting_zcml,
+ self.package.__name__, layer_name)
# Passing a ready-for-use layer overrides layer specified by
# zcml_config...
if layer is not None:
Modified: z3c.testsetup/trunk/src/z3c/testsetup/functionaldoctestsetup.txt
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/functionaldoctestsetup.txt 2008-02-17 00:35:43 UTC (rev 83964)
+++ z3c.testsetup/trunk/src/z3c/testsetup/functionaldoctestsetup.txt 2008-02-17 01:00:45 UTC (rev 83965)
@@ -394,17 +394,54 @@
- `zcml_config`
+ The path to a ZCML file, often named `ftesting.zcml`. If a
+ package, provides a file `ftesting.zcml` in its root, then this is
+ taken as default. The ``cave_to_let`` package in the tests/
+ directory provides such an `ftesting.zcml`::
+
+ >>> from z3c.testsetup.tests import cave_to_let
+ >>> setup = FunctionalDocTestSetup(cave_to_let)
+ >>> pnorm(setup.layer.config_file)
+ '.../tests/cave_to_let/ftesting.zcml'
+
+ The fallback-solution is to take the layer from the
+ `z3c.testsetup` package::
+
+ >>> setup = FunctionalDocTestSetup(cave)
+ >>> pnorm(setup.layer.config_file)
+ '...z3c/testsetup/ftesting.zcml'
+
+ Now the fallback `ftesting.zcml` was taken, because the cave got
+ no own ftesting.zcml.
+
- `layer_name`
+ A string. The default is ``FunctionalLayer``.
+
- `layer`
+ A ``zope.app.testing.functional.ZCMLLayer`` object. Setting a
+ layer overrides `zcml_config` and `layer_name`.
+
Their usage is explained in the next section.
Cutomizing the ZCML layer
+++++++++++++++++++++++++
-The ZCML layer registered by default by ``z3c.testsetup`` is very
+The ZCML layer of a FunctionalDocTestSetup is searched in four steps:
+
+1) If a setup is called with `layer` parameter, take this.
+
+2) If a setup is called with `zcml_config` paramter, take this.
+
+3) If an `ftesting.zcml` can be found in the root of the package to
+ search, take this (default).
+
+4) Take the (very poor) ftesting.zcml of the z3c.testsetup package
+ (fallback).
+
+The ZCML layer registered as fallback by ``z3c.testsetup`` is very
poor. In fact it only exists, to satisfy dependencies. In most cases,
you would like to write your own ZCML configuration to register
principals etc. during functional doctests.
Added: z3c.testsetup/trunk/src/z3c/testsetup/tests/cave_to_let/__init__.py
===================================================================
Added: z3c.testsetup/trunk/src/z3c/testsetup/tests/cave_to_let/ftesting.zcml
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/cave_to_let/ftesting.zcml (rev 0)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/cave_to_let/ftesting.zcml 2008-02-17 01:00:45 UTC (rev 83965)
@@ -0,0 +1,14 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="zope"
+ >
+
+ <!--
+ This is only a dummy layer to enable local tests and avoid
+ dependencies from packages we do not need badly.
+
+ For tests that include testbrowser tests and similar, write your
+ own ftesting.zcml with registration of principals etc.
+ -->
+
+</configure>
More information about the Checkins
mailing list