[Checkins]
SVN: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/test
Add tests for uglobs and fglobs parameters.
Uli Fouquet
uli at gnufix.de
Thu Feb 14 09:10:07 EST 2008
Log message for revision 83835:
Add tests for uglobs and fglobs parameters.
Changed:
U Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testrunner.txt
A Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short8.py
A Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short9.py
-=-
Modified: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testrunner.txt
===================================================================
--- Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testrunner.txt 2008-02-14 14:07:42 UTC (rev 83834)
+++ Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/testrunner.txt 2008-02-14 14:10:07 UTC (rev 83835)
@@ -291,8 +291,12 @@
You can pass the globals for a testsetup by passing the ``globs``
keyword parameter or ``fglobs``/``uglobs``, if you only want them to
-be applied to either functional or unit doctests.
+be applied to either functional or unit doctests.
+If you specify a `globs` parameter and a `fglobs` or `uglobs`
+parameter, the latter will shadow the `globs` values. So `globs` will
+have no effect, if you specify also both, `fglobs` and `uglobs`.
+
An example of the ``globs`` usage can be found in
``samplesetup_short7`` of the ``cave`` package::
@@ -330,8 +334,67 @@
The testrunner finished without any error. So the ``basename``
function was indeed known to the doctest and could be used.
+The same should happen, if we use the ``fglobs`` argument instead of
+``globs``::
+ >>> setupfile = os.path.join(cavepath, 'samplesetup_short8.py')
+ >>> print open(setupfile).read()
+ import os
+ ...
+ test_suite = z3c.testsetup.register_all_tests(
+ 'z3c.testsetup.tests.cave',
+ extensions = ['.chk',],
+ fregexp_list = [':Test-Layer:.*globs.*',],
+ fglobs = {
+ 'basename' : os.path.basename
+ }
+ )
+ >>> defaults = [
+ ... '--path', cavepath,
+ ... '--tests-pattern', '^samplesetup_short8$',
+ ... ]
+ >>> sys.argv = 'test -f '.split()
+ >>> testrunner.run(defaults)
+ Running z3c.testsetup.doctesting.FunctionalLayer tests:
+ ...
+ Ran 1 tests with 0 failures and 0 errors in ... seconds.
+ ...
+ False
+
+Finally, we can register the same doctestfile as unit doctest, such
+making sure, that also unit doctests globals can be set, using the
+``uglobs`` keyword parameter::
+
+ >>> setupfile = os.path.join(cavepath, 'samplesetup_short9.py')
+ >>> print open(setupfile).read()
+ import os
+ ...
+ test_suite = z3c.testsetup.register_all_tests(
+ 'z3c.testsetup.tests.cave',
+ extensions = ['.chk',],
+ uregexp_list = [':Test-Layer:.*globs.*',],
+ uglobs = {
+ 'basename' : os.path.basename
+ }
+ )
+
+ >>> defaults = [
+ ... '--path', cavepath,
+ ... '--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.
+ False
+
+
+
+
+
+
+
Extended setups
---------------
Added: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short8.py
===================================================================
--- Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short8.py (rev 0)
+++ Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short8.py 2008-02-14 14:10:07 UTC (rev 83835)
@@ -0,0 +1,11 @@
+import os
+from zope.testing import renormalizing
+import z3c.testsetup
+test_suite = z3c.testsetup.register_all_tests(
+ 'z3c.testsetup.tests.cave',
+ extensions = ['.chk',],
+ fregexp_list = [':Test-Layer:.*globs.*',],
+ fglobs = {
+ 'basename' : os.path.basename
+ }
+ )
Added: Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short9.py
===================================================================
--- Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short9.py (rev 0)
+++ Sandbox/ulif/z3c-testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_short9.py 2008-02-14 14:10:07 UTC (rev 83835)
@@ -0,0 +1,11 @@
+import os
+from zope.testing import renormalizing
+import z3c.testsetup
+test_suite = z3c.testsetup.register_all_tests(
+ 'z3c.testsetup.tests.cave',
+ extensions = ['.chk',],
+ uregexp_list = [':Test-Layer:.*globs.*',],
+ uglobs = {
+ 'basename' : os.path.basename
+ }
+ )
More information about the Checkins
mailing list