[Zope3-checkins] SVN: zope.testing/trunk/src/zope/testing/testrunner Changed the --module option to match against dotted module names

Jim Fulton jim at zope.com
Tue Nov 1 16:23:17 EST 2005


Log message for revision 39827:
  Changed the --module option to match against dotted module names
  rather than module file path names.
  

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 20:22:32 UTC (rev 39826)
+++ zope.testing/trunk/src/zope/testing/testrunner-test-selection.txt	2005-11-01 21:23:17 UTC (rev 39827)
@@ -47,7 +47,7 @@
 You can specify multiple packages:
 
     >>> sys.argv = 'test -u  -vv -ssample1 -ssample2'.split()
-    >>> testrunner.run(defaults) # doctest: +REPORT_NDIFF
+    >>> testrunner.run(defaults) 
     Running tests at level 1
     Running unit tests:
       Running:
@@ -158,7 +158,7 @@
       Ran 128 tests with 0 failures and 0 errors in 0.025 seconds.
     False
 
-We can select by test module name:
+We can select by test module name using the --moduke (-m) option:
 
     >>> sys.argv = 'test -u  -vv -ssample1 -m_one -mtest1'.split()
     >>> testrunner.run(defaults)
@@ -194,7 +194,7 @@
       Ran 32 tests with 0 failures and 0 errors in 0.008 seconds.
     False
 
-and by test within the module:
+and by test within the module using the --test (-t) option:
 
     >>> sys.argv = 'test -u  -vv -ssample1 -m_one -mtest1 -tx0 -ty0'.split()
     >>> testrunner.run(defaults)
@@ -226,7 +226,58 @@
       Ran 20 tests with 0 failures and 0 errors in 0.004 seconds.
     False
 
-Sometimes, there are tests that you don't want to run by default.
+The --moduke and --test options take regular expressions.  If the
+regular expressions specified begin with '!', then tests that don't
+match the regular expression are selected:
+
+    >>> sys.argv = 'test -u  -vv -ssample1 -m!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.
+
+
+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
 assumed and, by default, only tests at level one are run.  to run

Modified: zope.testing/trunk/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner.py	2005-11-01 20:22:32 UTC (rev 39826)
+++ zope.testing/trunk/src/zope/testing/testrunner.py	2005-11-01 21:23:17 UTC (rev 39827)
@@ -913,6 +913,12 @@
                 module_name = noext.replace(os.path.sep, '.')
                 if package:
                     module_name = package + '.' + module_name
+
+                for filter in options.module:
+                    if filter(module_name):
+                        break
+                else:
+                    continue
                     
                 try:
                     module = import_name(module_name)
@@ -964,13 +970,9 @@
 def find_test_files(options):
     found = {}
     for f, package in find_test_files_(options):
-        if f in found:
-            continue
-        for filter in options.module:
-            if filter(f):
-                found[f] = 1
-                yield f, package
-                break
+        if f not in found:
+            found[f] = 1
+            yield f, package
 
 identifier = re.compile(r'[_a-zA-Z]\w*$').match
 def find_test_files_(options):
@@ -1225,10 +1227,11 @@
     help="""\
 Specify a test-module filter as a regular expression.  This is a
 case-sensitive regular expression, used in search (not match) mode, to
-limit which test modules are searched for tests.  In an extension of
-Python regexp notation, a leading "!" is stripped and causes the sense
-of the remaining regexp to be negated (so "!bc" matches any string
-that does not match "bc", and vice versa).  The option can be
+limit which test modules are searched for tests.  The regular
+expressions are checked against dotted module names.  In an extension
+of Python regexp notation, a leading "!" is stripped and causes the
+sense of the remaining regexp to be negated (so "!bc" matches any
+string that does not match "bc", and vice versa).  The option can be
 specified multiple test-module filters.  Test modules matching any of
 the test filters are searched.  If no test-module filter is specified,
 then all test moduless are used.



More information about the Zope3-Checkins mailing list