[Checkins]
SVN: z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/
Add a testing environment for layered tests.
Uli Fouquet
uli at gnufix.de
Mon Jul 28 06:51:34 EDT 2008
Log message for revision 88856:
Add a testing environment for layered tests.
Changed:
A z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/
A z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/__init__.py
A z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/adoctest.txt
A z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layer.py
A z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layeredsetup01.py
-=-
Added: z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/__init__.py
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/__init__.py (rev 0)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/__init__.py 2008-07-28 10:51:34 UTC (rev 88856)
@@ -0,0 +1 @@
+# a package
Added: z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/adoctest.txt
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/adoctest.txt (rev 0)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/adoctest.txt 2008-07-28 10:51:34 UTC (rev 88856)
@@ -0,0 +1,10 @@
+This is a doctest
+=================
+
+This doctest will be applied to a layer.
+
+:Test-Layer: unit
+:Test-Layerdef: z3c.testsetup.tests.layered_cave.layer.UnitLayer1
+
+ >>> 1+1
+ 2
Added: z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layer.py
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layer.py (rev 0)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layer.py 2008-07-28 10:51:34 UTC (rev 88856)
@@ -0,0 +1,49 @@
+
+layer_marker = None
+
+class UnitLayer1(object):
+ """This represents a layer.
+ A layer is a way to have common setup and teardown that happens
+ once for a whole group of tests.
+
+ It must be an object with a `setUp` and a `tearDown` method, which
+ are run once before or after all the tests applied to a layer
+ respectively.
+
+ Optionally you can additionally define `testSetUp` and
+ `testTearDown` methods, which are run before and after each single
+ test.
+
+ This class is not instantiated. Therefore we use classmethods.
+ """
+
+ @classmethod
+ def setUp(self):
+ """This gets run once for the whole test run, or at most once per
+ TestSuite that depends on the layer.
+ (The latter can happen if multiple suites depend on the layer
+ and the testrunner decides to tear down the layer after first
+ suite finishes.)
+ """
+
+ @classmethod
+ def tearDown(self):
+ """This gets run once for the whole test run, or at most
+ once per TestSuite that depends on the layer,
+ after all tests in the suite have finished.
+ """
+
+ @classmethod
+ def testSetUp(self):
+ """This method is run before each single test in the current
+ layer. It is optional.
+ """
+ print " Running testSetUp of UnitLayer1"
+
+ @classmethod
+ def testTearDown(self):
+ """This method is run before each single test in the current
+ layer. It is optional.
+ """
+ print " Running testTearDown of UnitLayer1"
+
Added: z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layeredsetup01.py
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layeredsetup01.py (rev 0)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layeredsetup01.py 2008-07-28 10:51:34 UTC (rev 88856)
@@ -0,0 +1,2 @@
+from z3c.testsetup import register_all_tests
+test_suite = register_all_tests('z3c.testsetup.tests.layered_cave')
More information about the Checkins
mailing list