[Checkins]
SVN: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/test
Add tests for dotted name packages.
Uli Fouquet
uli at gnufix.de
Sat Feb 2 16:06:23 EST 2008
Log message for revision 83430:
Add tests for dotted name packages.
Changed:
U Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testrunner.txt
A Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short1.py
-=-
Modified: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testrunner.txt
===================================================================
--- Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testrunner.txt 2008-02-02 17:19:05 UTC (rev 83429)
+++ Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testrunner.txt 2008-02-02 21:06:23 UTC (rev 83430)
@@ -9,8 +9,45 @@
Short setups
------------
+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', 'cave')
+ >>> setupfile = os.path.join(cavepath, 'samplesetup_short1.py')
+ >>> print open(setupfile).read()
+ import z3c.testsetup
+ <BLANKLINE>
+ test_suite = z3c.testsetup.register_doctests('z3c.testsetup.tests.cave')
+
+This means, that we want to register all doctests 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_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.
+ False
+
+In the above setup the handled package was given as a string with
+dotted name notation. We can instead also pass the package itself, if
+it was loaded before. This results in a slight longer example::
+
+ >>> #import os
+ >>> #cavepath = os.path.join(os.path.dirname(__file__), 'tests', 'cave')
>>> setupfile = os.path.join(cavepath, 'samplesetup_short2.py')
>>> print open(setupfile).read()
import z3c.testsetup
Added: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short1.py
===================================================================
--- Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short1.py (rev 0)
+++ Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short1.py 2008-02-02 21:06:23 UTC (rev 83430)
@@ -0,0 +1,3 @@
+import z3c.testsetup
+
+test_suite = z3c.testsetup.register_doctests('z3c.testsetup.tests.cave')
More information about the Checkins
mailing list