Rev 2926: * The ``exclude_pattern`` parameter to the ``bzrlib.tests.`` functions in http://people.ubuntu.com/~robertc/baz2.0/in-module-parameterisation

Robert Collins robertc at robertcollins.net
Sun Oct 21 00:43:46 BST 2007


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

------------------------------------------------------------
revno: 2926
revision-id: robertc at robertcollins.net-20071020234331-djq3v6djt8dptt22
parent: robertc at robertcollins.net-20071020231134-a54h5s14128g72l6
committer: Robert Collins <robertc at robertcollins.net>
branch nick: in-module-parameterisation
timestamp: Sun 2007-10-21 09:43:31 +1000
message:
  * The ``exclude_pattern`` parameter to the ``bzrlib.tests.`` functions
    ``filter_suite_by_re`` and ``sort_suite_by_re`` has been deprecated.
    (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
=== modified file 'NEWS'
--- a/NEWS	2007-10-20 23:01:54 +0000
+++ b/NEWS	2007-10-20 23:43:31 +0000
@@ -276,6 +276,10 @@
    * New transport implementation ``trace+`` which is useful for testing,
      logging activity taken to its _activity attribute. (Robert Collins)
 
+   * The ``exclude_pattern`` parameter to the ``bzrlib.tests.`` functions
+     ``filter_suite_by_re`` and ``sort_suite_by_re`` has been deprecated.
+     (Robert Collins)
+
    * When running bzr commands within the test suite, internal exceptions are
      not caught and reported in the usual way, but rather allowed to propagate
      up and be visible to the test suite.  A new API ``run_bzr_catch_user_errors``

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2007-10-20 23:11:34 +0000
+++ b/bzrlib/tests/__init__.py	2007-10-20 23:43:31 +0000
@@ -77,6 +77,8 @@
 import bzrlib.store
 from bzrlib import symbol_versioning
 from bzrlib.symbol_versioning import (
+    DEPRECATED_PARAMETER,
+    deprecated_passed,
     deprecated_method,
     zero_ninetyone,
     zero_ninetytwo,
@@ -2194,19 +2196,25 @@
             self.transport_readonly_server = HttpServer
 
 
-def filter_suite_by_re(suite, pattern, exclude_pattern=None,
+def filter_suite_by_re(suite, pattern, exclude_pattern=DEPRECATED_PARAMETER,
                        random_order=False):
     """Create a test suite by filtering another one.
     
     :param suite:           the source suite
     :param pattern:         pattern that names must match
-    :param exclude_pattern: pattern that names must not match, if any
+    :param exclude_pattern: A pattern that names must not match. This parameter
+        is deprecated as of bzrlib 0.92. Please use the separate function
+        exclude_tests_by_re instead.
     :param random_order:    if True, tests in the new suite will be put in
                             random order
     :returns: the newly created suite
     """ 
-    if exclude_pattern is not None:
-        suite = exclude_tests_by_re(suite, exclude_pattern)
+    if deprecated_passed(exclude_pattern):
+        symbol_versioning.warn(
+            zero_ninetytwo % "passing exclude_pattern to filter_suite_by_re",
+                DeprecationWarning, stacklevel=2)
+        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):
@@ -2245,7 +2253,7 @@
     return TestUtil.TestSuite(tests)
 
 
-def sort_suite_by_re(suite, pattern, exclude_pattern=None,
+def sort_suite_by_re(suite, pattern, exclude_pattern=DEPRECATED_PARAMETER,
                      random_order=False, append_rest=True):
     """Create a test suite by sorting another one.
     
@@ -2260,8 +2268,12 @@
                             just an ordering directive
     :returns: the newly created suite
     """ 
-    if exclude_pattern is not None:
-        suite = exclude_tests_by_re(suite, exclude_pattern)
+    if deprecated_passed(exclude_pattern):
+        symbol_versioning.warn(
+            zero_ninetytwo % "passing exclude_pattern to filter_suite_by_re",
+                DeprecationWarning, stacklevel=2)
+        if exclude_pattern is not None:
+            suite = exclude_tests_by_re(suite, exclude_pattern)
     if append_rest:
         suites = split_suite_by_re(suite, pattern)
     else:
@@ -2336,13 +2348,14 @@
             (random_seed))
         random.seed(random_seed)
     # Customise the list of tests if requested
-    if pattern != '.*' or exclude_pattern is not None or random_order:
+    if exclude_pattern is not None:
+        suite = exclude_pattern(suite, pattern)
+    if pattern != '.*' or random_order:
         if matching_tests_first:
-            suite = sort_suite_by_re(suite, pattern, exclude_pattern,
-                random_order)
+            suite = sort_suite_by_re(suite, pattern, random_order=random_order)
         else:
-            suite = filter_suite_by_re(suite, pattern, exclude_pattern,
-                random_order)
+            suite = filter_suite_by_re(suite, pattern,
+                random_order=random_order)
     result = runner.run(suite)
 
     if strict:



More information about the bazaar-commits mailing list