[Checkins] SVN: z3c.testsetup/branches/0.2/src/z3c/testsetup/ Update doctest examples to reflect new zope.testing behaviour.
Uli Fouquet
uli at gnufix.de
Mon Sep 1 10:08:48 EDT 2008
Log message for revision 90646:
Update doctest examples to reflect new zope.testing behaviour.
Changed:
U z3c.testsetup/branches/0.2/src/z3c/testsetup/nozopeapptesting.txt
U z3c.testsetup/branches/0.2/src/z3c/testsetup/testrunner.txt
U z3c.testsetup/branches/0.2/src/z3c/testsetup/tests/test_testsetup.py
-=-
Modified: z3c.testsetup/branches/0.2/src/z3c/testsetup/nozopeapptesting.txt
===================================================================
--- z3c.testsetup/branches/0.2/src/z3c/testsetup/nozopeapptesting.txt 2008-09-01 13:53:14 UTC (rev 90645)
+++ z3c.testsetup/branches/0.2/src/z3c/testsetup/nozopeapptesting.txt 2008-09-01 14:08:48 UTC (rev 90646)
@@ -59,8 +59,11 @@
>>> sys.argv = 'test '.split()
>>> from zope.testing import testrunner
>>> testrunner.run(defaults)
- Running unit tests:
+ Running zope.testing.testrunner.layer.UnitTests tests:
+ Set up zope.testing.testrunner.layer.UnitTests in ... seconds.
Ran 2 tests with 0 failures and 0 errors in ... seconds.
+ Tearing down left over layers:
+ Tear down zope.testing.testrunner.layer.UnitTests in ... seconds.
False
As we can see, only unit test were run and no functional ones anymore.
Modified: z3c.testsetup/branches/0.2/src/z3c/testsetup/testrunner.txt
===================================================================
--- z3c.testsetup/branches/0.2/src/z3c/testsetup/testrunner.txt 2008-09-01 13:53:14 UTC (rev 90645)
+++ z3c.testsetup/branches/0.2/src/z3c/testsetup/testrunner.txt 2008-09-01 14:08:48 UTC (rev 90646)
@@ -19,27 +19,33 @@
import z3c.testsetup
test_suite = z3c.testsetup.register_all_tests('z3c.testsetup.tests.cave')
+We clear the commandline, because all parameters passed to the
+commandline would otherwise be applied to the examples herein::
+
+ >>> import sys
+ >>> sys.argv = [sys.argv[0],]
+
This means, that we want to register all tests (doctests and 'normal'
python tests) from the ``cave`` package, whose name we passed in
dotted name notation as a string. This is enough information for a
testrunner::
- >>> import sys
>>> defaults = [
... '--path', cavepath,
... '--tests-pattern', '^samplesetup_short0$',
... ]
- >>> sys.argv = 'test '.split()
>>> from zope.testing import testrunner
>>> testrunner.run(defaults)
- Running unit tests:
- Ran 2 tests with 0 failures and 0 errors in ... seconds.
Running z3c.testsetup.functional.doctesting.FunctionalLayer tests:
- Set up z3c.testsetup....doctesting.FunctionalLayer in ... seconds.
- Ran 2 tests with 0 failures and 0 errors in ... seconds.
- Tearing down left over layers:
- Tear down z3c.testsetup....doctesting.FunctionalLayer ... not supported
- Total: 4 tests, 0 failures, 0 errors in ... seconds.
+ Set up z3c...functional.doctesting.FunctionalLayer in N.NNN seconds.
+ Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
+ Running zope.testing.testrunner.layer.UnitTests tests:
+ Tear down z3c...functional.doctesting.FunctionalLayer ... not supported
+ Running in a subprocess.
+ Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
+ Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Total: 4 tests, 0 failures, 0 errors in N.NNN seconds.
False
Of the four tests apparently run, there is one 'normal' python test
@@ -63,17 +69,17 @@
... '--path', cavepath,
... '--tests-pattern', '^samplesetup_short1$',
... ]
- >>> sys.argv = 'test '.split()
- >>> from zope.testing import testrunner
>>> testrunner.run(defaults)
- Running unit tests:
- Ran 1 tests with 0 failures and 0 errors in ... seconds.
- Running z3c.testsetup....doctesting.FunctionalLayer tests:
- Set up z3c.testsetup....doctesting.FunctionalLayer in ... seconds.
- Ran 2 tests with 0 failures and 0 errors in ... seconds.
- Tearing down left over layers:
- Tear down z3c.testsetup....doctesting.FunctionalLayer ... not supported
- Total: 3 tests, 0 failures, 0 errors in ... seconds.
+ Running z3c.testsetup.functional.doctesting.FunctionalLayer tests:
+ Set up z3c.testsetup...doctesting.FunctionalLayer in N.NNN seconds.
+ Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
+ Running zope.testing.testrunner.layer.UnitTests tests:
+ Tear down z3c.testsetup...doctesting.FunctionalLayer ... not supported
+ Running in a subprocess.
+ Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
+ Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Total: 3 tests, 0 failures, 0 errors in N.NNN seconds.
False
In the above setup the handled package was given as a string with
@@ -95,17 +101,17 @@
... '--path', cavepath,
... '--tests-pattern', '^samplesetup_short2$',
... ]
- >>> sys.argv = 'test '.split()
- >>> from zope.testing import testrunner
>>> testrunner.run(defaults)
- Running unit tests:
- Ran 1 tests with 0 failures and 0 errors in ... seconds.
- Running z3c.testsetup....doctesting.FunctionalLayer tests:
- Set up z3c.testsetup....doctesting.FunctionalLayer in ... seconds.
- Ran 2 tests with 0 failures and 0 errors in ... seconds.
- Tearing down left over layers:
- Tear down z3c.testsetup....doctesting.FunctionalLayer ... not supported
- Total: 3 tests, 0 failures, 0 errors in ... seconds.
+ Running z3c.testsetup.functional.doctesting.FunctionalLayer tests:
+ Set up z3c.testsetup...doctesting.FunctionalLayer in N.NNN seconds.
+ Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
+ Running zope.testing.testrunner.layer.UnitTests tests:
+ Tear down z3c.testsetup...doctesting.FunctionalLayer ... not supported
+ Running in a subprocess.
+ Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
+ Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Total: 3 tests, 0 failures, 0 errors in N.NNN seconds.
False
Now let's run a suite of 'normal' python unit tests, i.e. tests, that
@@ -118,7 +124,6 @@
<BLANKLINE>
test_suite = z3c.testsetup.register_pytests(cave)
-
The only difference to the example before is, that we use
`register_pytests` instead of `register_doctests`. If we run this
setup with the testrunner, one test should be found and executed. This
@@ -126,17 +131,18 @@
information from the run::
>>> defaults = [
- ... '--path', cavepath,
+ ... '--path', cavepath, '-vv',
... '--tests-pattern', '^samplesetup_short3$',
... ]
- >>> sys.argv = 'test -vv'.split()
- >>> from zope.testing import testrunner
>>> testrunner.run(defaults)
Running tests at level 1
- Running unit tests:
+ Running zope.testing.testrunner.layer.UnitTests tests:
+ Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
Running:
testFoo (z3c.testsetup.tests.cave.file1.TestTest)
- Ran 1 tests with 0 failures and 0 errors in ... seconds.
+ Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
+ Tearing down left over layers:
+ Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
False
@@ -176,17 +182,17 @@
... '--path', cavepath,
... '--tests-pattern', '^samplesetup_short4$',
... ]
- >>> sys.argv = 'test '.split()
- >>> from zope.testing import testrunner
>>> testrunner.run(defaults)
- Running unit tests:
- Ran 2 tests with 0 failures and 0 errors in ... seconds.
Running z3c.testsetup.tests.cave.SampleLayer tests:
- Set up z3c.testsetup.tests.cave.SampleLayer in ... seconds.
- Ran 2 tests with 0 failures and 0 errors in ... seconds.
- Tearing down left over layers:
+ Set up z3c.testsetup.tests.cave.SampleLayer in N.NNN seconds.
+ Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
+ Running zope.testing.testrunner.layer.UnitTests tests:
Tear down z3c.testsetup.tests.cave.SampleLayer ... not supported
- Total: 4 tests, 0 failures, 0 errors in ... seconds.
+ Running in a subprocess.
+ Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
+ Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Total: 4 tests, 0 failures, 0 errors in N.NNN seconds.
False
Apparently now the custom ZCML file in the ``cave`` package was used.
@@ -226,14 +232,13 @@
Running the testrunner with this setup will result in::
>>> defaults = [
- ... '--path', cavepath,
+ ... '--path', cavepath, '-f',
... '--tests-pattern', '^samplesetup_short5$',
... ]
- >>> sys.argv = 'test -f '.split()
>>> testrunner.run(defaults)
Running z3c.testsetup....doctesting.FunctionalLayer tests:
- Set up z3c.testsetup....doctesting.FunctionalLayer in ... seconds.
- Ran 2 tests with 0 failures and 0 errors in ... seconds.
+ Set up z3c.testsetup....doctesting.FunctionalLayer in N.NNN seconds.
+ Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
Tearing down left over layers:
Tear down z3c.testsetup....doctesting.FunctionalLayer ... not supported
False
@@ -241,10 +246,9 @@
The same setup, but without a modified checker will deliver::
>>> defaults = [
- ... '--path', cavepath,
+ ... '--path', cavepath, '-f',
... '--tests-pattern', '^samplesetup_short6$',
... ]
- >>> sys.argv = 'test -f '.split()
>>> testrunner.run(defaults)
Running z3c.testsetup....doctesting.FunctionalLayer tests:
Set up z3c.testsetup....doctesting.FunctionalLayer in ... seconds.
@@ -319,10 +323,9 @@
``globstest.chk``::
>>> defaults = [
- ... '--path', cavepath,
+ ... '--path', cavepath, '-f',
... '--tests-pattern', '^samplesetup_short7$',
... ]
- >>> sys.argv = 'test -f '.split()
>>> testrunner.run(defaults)
Running z3c.testsetup....doctesting.FunctionalLayer tests:
Set up z3c.testsetup....doctesting.FunctionalLayer in ... seconds.
@@ -351,10 +354,9 @@
)
>>> defaults = [
- ... '--path', cavepath,
+ ... '--path', cavepath, '-f',
... '--tests-pattern', '^samplesetup_short8$',
... ]
- >>> sys.argv = 'test -f '.split()
>>> testrunner.run(defaults)
Running z3c.testsetup....doctesting.FunctionalLayer tests:
...
@@ -380,21 +382,20 @@
)
>>> defaults = [
- ... '--path', cavepath,
+ ... '--path', cavepath, '-u',
... '--tests-pattern', '^samplesetup_short9$',
... ]
- >>> sys.argv = 'test -u '.split()
>>> testrunner.run(defaults)
- Running unit tests:
- Ran 2 tests with 0 failures and 0 errors in ... seconds.
+ Running zope.testing.testrunner.layer.UnitTests tests:
+ Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
+ Tearing down left over layers:
+ Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
False
-
-
-
Extended setups
---------------
@@ -429,17 +430,34 @@
... '--path', cavepath,
... '--tests-pattern', '^samplesetup1$',
... ]
- >>> sys.argv = 'test '.split()
>>> from zope.testing import testrunner
>>> testrunner.run(defaults)
- Running unit tests:
- Ran 1 tests with 0 failures and 0 errors in ... seconds.
- Running z3c.testsetup....doctesting.FunctionalLayer tests:
- Set up z3c.testsetup....doctesting.FunctionalLayer in ... seconds.
- Ran 2 tests with 0 failures and 0 errors in ... seconds.
- Tearing down left over layers:
- Tear down z3c.testsetup....doctesting.FunctionalLayer ... not supported
- Total: 3 tests, 0 failures, 0 errors in ... seconds.
+ Running z3c.testsetup.functional.doctesting.FunctionalLayer tests:
+ Set up z3c.testsetup...doctesting.FunctionalLayer in N.NNN seconds.
+ Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
+ Running zope.testing.testrunner.layer.UnitTests tests:
+ Tear down z3c.testsetup...doctesting.FunctionalLayer ... not supported
+ Running in a subprocess.
+ Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
+ Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Total: 3 tests, 0 failures, 0 errors in N.NNN seconds.
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.
+
+
Modified: z3c.testsetup/branches/0.2/src/z3c/testsetup/tests/test_testsetup.py
===================================================================
--- z3c.testsetup/branches/0.2/src/z3c/testsetup/tests/test_testsetup.py 2008-09-01 13:53:14 UTC (rev 90645)
+++ z3c.testsetup/branches/0.2/src/z3c/testsetup/tests/test_testsetup.py 2008-09-01 14:08:48 UTC (rev 90646)
@@ -4,6 +4,7 @@
import re
import unittest
from zope.testing import doctest, cleanup, renormalizing
+from zope.testing.testrunner.tests import checker
import zope.component.eventtesting
from z3c.testsetup.util import get_package
@@ -53,14 +54,8 @@
def cleanUpZope(test):
cleanup.cleanUp()
-checker = renormalizing.RENormalizing([
- # str(Exception) has changed from Python 2.4 to 2.5 (due to
- # Exception now being a new-style class). This changes the way
- # exceptions appear in traceback printouts.
- (re.compile(r"ConfigurationExecutionError: <class '([\w.]+)'>:"),
- r'ConfigurationExecutionError: \1:'),
- ])
+
def testrunner_suite():
def setUp(test):
test.globs['saved-sys-info'] = (
More information about the Checkins
mailing list