[Checkins] SVN: z3c.testsetup/branches/new_markers/src/z3c/testsetup/ Move layerrunner tests to testrunner tests.
Uli Fouquet
uli at gnufix.de
Wed Aug 27 13:09:47 EDT 2008
Log message for revision 90469:
Move layerrunner tests to testrunner tests.
Changed:
D z3c.testsetup/branches/new_markers/src/z3c/testsetup/layerrunner.txt
U z3c.testsetup/branches/new_markers/src/z3c/testsetup/testrunner.txt
-=-
Deleted: z3c.testsetup/branches/new_markers/src/z3c/testsetup/layerrunner.txt
===================================================================
--- z3c.testsetup/branches/new_markers/src/z3c/testsetup/layerrunner.txt 2008-08-27 14:59:55 UTC (rev 90468)
+++ z3c.testsetup/branches/new_markers/src/z3c/testsetup/layerrunner.txt 2008-08-27 17:09:46 UTC (rev 90469)
@@ -1,81 +0,0 @@
-========================
-z3c.testsetup and layers
-========================
-
-Here we discuss complete testsetups that involve test layers. Test
-layers are a method to group several tests or test suites in groups.
-
-Layers are a method to do time-consuming setups like initializing
-databases or whatever only once for a whole bunch of tests. Such you
-can save time and make your testing setup less error-prone.
-
-See `layered_cave/layer.py` for examples of working layers. We will
-use the layers defined there in the following examples.
-
-Simple unit doctests with layers
---------------------------------
-
-Using z3c.testsetup, we can define quite complex testsetups with only
-two lines of code::
-
- >>> import os
- >>> cavepath = os.path.join(os.path.dirname(__file__), 'tests',
- ... 'layered_cave')
- >>> setupfile = os.path.join(cavepath, 'layeredsetup01.py')
- >>> print open(setupfile).read()
- from z3c.testsetup import register_all_tests
- test_suite = register_all_tests('z3c.testsetup.tests.layered_cave')
-
-This means, that we want to register all tests (doctests and 'normal'
-python tests) from the ``layered_cave`` package, whose name we passed in
-dotted name notation as a string. This is enough information for a
-testrunner.
-
-In one of the test files we declared, that a layer should be used::
-
- >>> testfile = os.path.join(cavepath, 'adoctest.txt')
- >>> print open(testfile, 'r').read()
- This is a doctest
- =================
- <BLANKLINE>
- This doctest will be applied to a layer.
- <BLANKLINE>
- :Test-Layer: unit
- :Test-Layerdef: z3c.testsetup.tests.layered_cave.layer.UnitLayer1
- ...
-
-The line saying `:Test-Layerdef:` tells, that we want the layer
-denoted by the trailing dotted name should be applied to the tests of
-the file. It is vital that the denoted object really exist. The format
-of the layer declaration is::
-
- :Test-Layerdef: <dotted.name.of.layer.definition>
-
-where the marker string can be written in upper or lower or mixed
-case. Doing so, the testrunner will apply the declared layer to our
-tests::
-
- >>> import sys
- >>> defaults = [
- ... '--path', cavepath,
- ... '--tests-pattern', '^layeredsetup01$',
- ... ]
- >>> sys.argv = 'test -f'.split()
- >>> from zope.testing import testrunner
- >>> testrunner.run(defaults)
- Running z3c.testsetup.tests.layered_cave.layer.FunctionalLayer1 tests:
- Set up z3c.testsetup...yered_cave.layer.FunctionalLayer1 in ... seconds.
- Ran 1 tests with 0 failures and 0 errors in ... seconds.
- Running z3c.testsetup.tests.layered_cave.layer.UnitLayer1 tests:
- Tear down z3c.testsetup...red_cave.layer.FunctionalLayer1 in ... seconds.
- Set up z3c.testsetup...layered_cave.layer.UnitLayer1 in ... seconds.
- Running testSetUp of UnitLayer1
- Running testTearDown of UnitLayer1
- Ran 1 tests with 0 failures and 0 errors in ... seconds.
- Tearing down left over layers:
- Tear down z3c.testsetup...layered_cave.layer.UnitLayer1 in ... seconds.
- Total: 2 tests, 0 failures, 0 errors in ... seconds.
- False
-
-As we can see, the layer `UnitLayer1` was executed here.
-
Modified: z3c.testsetup/branches/new_markers/src/z3c/testsetup/testrunner.txt
===================================================================
--- z3c.testsetup/branches/new_markers/src/z3c/testsetup/testrunner.txt 2008-08-27 14:59:55 UTC (rev 90468)
+++ z3c.testsetup/branches/new_markers/src/z3c/testsetup/testrunner.txt 2008-08-27 17:09:46 UTC (rev 90469)
@@ -443,3 +443,85 @@
False
We ran one unittest and two functional tests.
+
+
+z3c.testsetup and layers
+========================
+
+Here we discuss complete testsetups that involve test layers. Test
+layers are a method to group several tests or test suites in groups.
+
+Layers are a method to do time-consuming setups like initializing
+databases or whatever only once for a whole bunch of tests. Such you
+can save time and make your testing setup less error-prone.
+
+See `layered_cave/layer.py` for examples of working layers. We will
+use the layers defined there in the following examples.
+
+Simple unit doctests with layers
+--------------------------------
+
+Using z3c.testsetup, we can define quite complex testsetups with only
+two lines of code::
+
+ >>> import os
+ >>> cavepath = os.path.join(os.path.dirname(__file__), 'tests',
+ ... 'layered_cave')
+ >>> setupfile = os.path.join(cavepath, 'layeredsetup01.py')
+ >>> print open(setupfile).read()
+ from z3c.testsetup import register_all_tests
+ test_suite = register_all_tests('z3c.testsetup.tests.layered_cave')
+
+This means, that we want to register all tests (doctests and 'normal'
+python tests) from the ``layered_cave`` package, whose name we passed in
+dotted name notation as a string. This is enough information for a
+testrunner.
+
+In one of the test files we declared, that a layer should be used::
+
+ >>> testfile = os.path.join(cavepath, 'adoctest.txt')
+ >>> print open(testfile, 'r').read()
+ This is a doctest
+ =================
+ <BLANKLINE>
+ This doctest will be applied to a layer.
+ <BLANKLINE>
+ :Test-Layer: unit
+ :Test-Layerdef: z3c.testsetup.tests.layered_cave.layer.UnitLayer1
+ ...
+
+The line saying `:Test-Layerdef:` tells, that we want the layer
+denoted by the trailing dotted name should be applied to the tests of
+the file. It is vital that the denoted object really exist. The format
+of the layer declaration is::
+
+ :Test-Layerdef: <dotted.name.of.layer.definition>
+
+where the marker string can be written in upper or lower or mixed
+case. Doing so, the testrunner will apply the declared layer to our
+tests::
+
+ >>> import sys
+ >>> defaults = [
+ ... '--path', cavepath,
+ ... '--tests-pattern', '^layeredsetup01$',
+ ... ]
+ >>> sys.argv = 'test -f'.split()
+ >>> from zope.testing import testrunner
+ >>> testrunner.run(defaults)
+ Running z3c.testsetup.tests.layered_cave.layer.FunctionalLayer1 tests:
+ Set up z3c.testsetup...yered_cave.layer.FunctionalLayer1 in ... seconds.
+ Ran 1 tests with 0 failures and 0 errors in ... seconds.
+ Running z3c.testsetup.tests.layered_cave.layer.UnitLayer1 tests:
+ Tear down z3c.testsetup...red_cave.layer.FunctionalLayer1 in ... seconds.
+ Set up z3c.testsetup...layered_cave.layer.UnitLayer1 in ... seconds.
+ Running testSetUp of UnitLayer1
+ Running testTearDown of UnitLayer1
+ Ran 1 tests with 0 failures and 0 errors in ... seconds.
+ Tearing down left over layers:
+ Tear down z3c.testsetup...layered_cave.layer.UnitLayer1 in ... seconds.
+ Total: 2 tests, 0 failures, 0 errors in ... seconds.
+ False
+
+As we can see, the layer `UnitLayer1` was executed here.
+
More information about the Checkins
mailing list