[Zope3-checkins]
SVN: zope.testing/trunk/src/zope/testing/testrunner
Fixed bugs in handling positional arguments.
Jim Fulton
jim at zope.com
Tue Nov 1 16:48:30 EST 2005
Log message for revision 39830:
Fixed bugs in handling positional arguments.
Changed:
U zope.testing/trunk/src/zope/testing/testrunner-test-selection.txt
U zope.testing/trunk/src/zope/testing/testrunner.py
-=-
Modified: zope.testing/trunk/src/zope/testing/testrunner-test-selection.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-test-selection.txt 2005-11-01 21:31:49 UTC (rev 39829)
+++ zope.testing/trunk/src/zope/testing/testrunner-test-selection.txt 2005-11-01 21:48:30 UTC (rev 39830)
@@ -231,7 +231,7 @@
match the regular expression are selected:
>>> sys.argv = 'test -u -vv -ssample1 -m!sample1[.]sample1'.split()
- >>> _ = testrunner.run(defaults)
+ >>> testrunner.run(defaults)
Running tests at level 1
Running unit tests:
Running:
@@ -275,8 +275,71 @@
test_z1 (sample1.sampletests.test_one)
testrunner-ex/sample1/sampletests/../../sampletests.txt
Ran 48 tests with 0 failures and 0 errors in 0.017 seconds.
+ False
+Module and test filters can also be given as positional arguments:
+
+ >>> sys.argv = 'test -u -vv -ssample1 !sample1[.]sample1'.split()
+ >>> testrunner.run(defaults)
+ Running tests at level 1
+ Running unit tests:
+ Running:
+ test_x1 (sample1.sampletestsf.TestA)
+ test_y0 (sample1.sampletestsf.TestA)
+ test_z0 (sample1.sampletestsf.TestA)
+ test_x0 (sample1.sampletestsf.TestB)
+ test_y1 (sample1.sampletestsf.TestB)
+ test_z0 (sample1.sampletestsf.TestB)
+ test_1 (sample1.sampletestsf.TestNotMuch)
+ test_2 (sample1.sampletestsf.TestNotMuch)
+ test_3 (sample1.sampletestsf.TestNotMuch)
+ test_x0 (sample1.sampletestsf)
+ test_y0 (sample1.sampletestsf)
+ test_z1 (sample1.sampletestsf)
+ testrunner-ex/sample1/../sampletests.txt
+ test_x1 (sample1.sampletests.test1.TestA)
+ test_y0 (sample1.sampletests.test1.TestA)
+ test_z0 (sample1.sampletests.test1.TestA)
+ test_x0 (sample1.sampletests.test1.TestB)
+ test_y1 (sample1.sampletests.test1.TestB)
+ test_z0 (sample1.sampletests.test1.TestB)
+ test_1 (sample1.sampletests.test1.TestNotMuch)
+ test_2 (sample1.sampletests.test1.TestNotMuch)
+ test_3 (sample1.sampletests.test1.TestNotMuch)
+ test_x0 (sample1.sampletests.test1)
+ test_y0 (sample1.sampletests.test1)
+ test_z1 (sample1.sampletests.test1)
+ testrunner-ex/sample1/sampletests/../../sampletests.txt
+ test_x1 (sample1.sampletests.test_one.TestA)
+ test_y0 (sample1.sampletests.test_one.TestA)
+ test_z0 (sample1.sampletests.test_one.TestA)
+ test_x0 (sample1.sampletests.test_one.TestB)
+ test_y1 (sample1.sampletests.test_one.TestB)
+ test_z0 (sample1.sampletests.test_one.TestB)
+ test_1 (sample1.sampletests.test_one.TestNotMuch)
+ test_2 (sample1.sampletests.test_one.TestNotMuch)
+ test_3 (sample1.sampletests.test_one.TestNotMuch)
+ test_x0 (sample1.sampletests.test_one)
+ test_y0 (sample1.sampletests.test_one)
+ test_z1 (sample1.sampletests.test_one)
+ testrunner-ex/sample1/sampletests/../../sampletests.txt
+ Ran 48 tests with 0 failures and 0 errors in 0.017 seconds.
+ False
+
+ >>> sys.argv = 'test -u -vv -ssample1 . txt'.split()
+ >>> testrunner.run(defaults)
+ Running tests at level 1
+ Running unit tests:
+ Running:
+ testrunner-ex/sample1/../sampletests.txt
+ testrunner-ex/sample1/sample11/../../sampletests.txt
+ testrunner-ex/sample1/sample13/../../sampletests.txt
+ testrunner-ex/sample1/sampletests/../../sampletests.txt
+ testrunner-ex/sample1/sampletests/../../sampletests.txt
+ Ran 20 tests with 0 failures and 0 errors in 0.004 seconds.
+ False
+
Sometimes, ere are tests that you don't want to run by default.
For example, you might have tests that take a long time. Tests can
have a level attribute. If no level is specified, a level of 1 is
Modified: zope.testing/trunk/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner.py 2005-11-01 21:31:49 UTC (rev 39829)
+++ zope.testing/trunk/src/zope/testing/testrunner.py 2005-11-01 21:48:30 UTC (rev 39830)
@@ -1590,7 +1590,7 @@
options.fail = False
if positional:
- module_filter = positional.pop()
+ module_filter = positional.pop(0)
if module_filter != '.':
if options.module:
options.module.append(module_filter)
@@ -1598,12 +1598,15 @@
options.module = [module_filter]
if positional:
- test_filter = [positional]
+ test_filter = positional.pop(0)
if options.test:
options.test.append(test_filter)
else:
options.test = [test_filter]
+ if positional:
+ parser.error("Too mant positional arguments")
+
options.ignore_dir = dict([(d,1) for d in options.ignore_dir])
options.test_file_pattern = re.compile(options.test_file_pattern).search
options.tests_pattern = re.compile(options.tests_pattern).search
More information about the Zope3-Checkins
mailing list