Rev 2925: Move the filter implementation of sort_tests_by_re back to filter_tests_by_re. in http://people.ubuntu.com/~robertc/baz2.0/in-module-parameterisation

Robert Collins robertc at robertcollins.net
Sun Oct 21 00:11:41 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/in-module-parameterisation

------------------------------------------------------------
revno: 2925
revision-id: robertc at robertcollins.net-20071020231134-a54h5s14128g72l6
parent: robertc at robertcollins.net-20071020230154-r22h8rsgpbhnw163
committer: Robert Collins <robertc at robertcollins.net>
branch nick: in-module-parameterisation
timestamp: Sun 2007-10-21 09:11:34 +1000
message:
  Move the filter implementation of sort_tests_by_re back to filter_tests_by_re.
modified:
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2007-10-20 23:01:54 +0000
+++ b/bzrlib/tests/__init__.py	2007-10-20 23:11:34 +0000
@@ -2205,8 +2205,18 @@
                             random order
     :returns: the newly created suite
     """ 
-    return sort_suite_by_re(suite, pattern, exclude_pattern,
-        random_order, False)
+    if exclude_pattern is not None:
+        suite = exclude_tests_by_re(suite, exclude_pattern)
+    result = []
+    filter_re = re.compile(pattern)
+    for test in iter_suite_tests(suite):
+        test_id = test.id()
+        if filter_re.search(test_id):
+            result.append(test)
+    result_suite = TestUtil.TestSuite(result)
+    if random_order:
+        result_suite = randomise_suite(result_suite)
+    return result_suite
 
 
 def exclude_tests_by_re(suite, pattern):
@@ -2244,7 +2254,8 @@
                             first in the new suite
     :param exclude_pattern: pattern that names must not match, if any
     :param random_order:    if True, tests in the new suite will be put in
-                            random order
+                            random order (with all tests matching pattern
+                            first).
     :param append_rest:     if False, pattern is a strict filter and not
                             just an ordering directive
     :returns: the newly created suite
@@ -2254,21 +2265,12 @@
     if append_rest:
         suites = split_suite_by_re(suite, pattern)
     else:
-        suites = [suite]
+        suites = [filter_suite_by_re(suite, pattern)]
     out_tests = []
     for suite in suites:
-        result = []
-        filter_re = re.compile(pattern)
-        for test in iter_suite_tests(suite):
-            test_id = test.id()
-            if append_rest:
-                result.append(test)
-            elif filter_re.search(test_id):
-                result.append(test)
-        result_suite = TestUtil.TestSuite(result)
         if random_order:
-            result_suite = randomise_suite(result_suite)
-        out_tests.append(result_suite)
+            suite = randomise_suite(suite)
+        out_tests.append(suite)
     return TestUtil.TestSuite(out_tests)
 
 



More information about the bazaar-commits mailing list