Rev 5373: Pull out the bits of changes to TestCase that I understand. in http://bazaar.launchpad.net/~jameinel/bzr/2.4-613247-cleanup-tests

John Arbash Meinel john at arbash-meinel.com
Thu May 19 18:39:53 UTC 2011


At http://bazaar.launchpad.net/~jameinel/bzr/2.4-613247-cleanup-tests

------------------------------------------------------------
revno: 5373
revision-id: john at arbash-meinel.com-20110519183939-7j7s512ep4ayds5j
parent: john at arbash-meinel.com-20110519182656-zcedexvff421nxi5
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.4-613247-cleanup-tests
timestamp: Thu 2011-05-19 20:39:39 +0200
message:
  Pull out the bits of changes to TestCase that I understand.
  
  Namely, clean out details when completed, and use the local variable for
  holding the log file, rather than creating a ref loop with self._log_file.
-------------- next part --------------
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/errors.py	2011-05-19 18:39:39 +0000
@@ -1659,7 +1659,6 @@
 
     def __init__(self, exc_info):
         import traceback
-        # GZ 2010-08-10: Cycle with exc_tb/exc_info affects at least one test
         self.exc_type, self.exc_value, self.exc_tb = exc_info
         self.exc_info = exc_info
         traceback_strings = traceback.format_exception(

=== modified file 'bzrlib/tests/TestUtil.py'
--- a/bzrlib/tests/TestUtil.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/TestUtil.py	2011-05-19 18:39:39 +0000
@@ -19,7 +19,6 @@
 import sys
 import logging
 import unittest
-import weakref
 
 from bzrlib import pyutils
 
@@ -83,36 +82,14 @@
         tests = list(self)
         tests.reverse()
         self._tests = []
-        stream = getattr(result, "stream", None)
-        # With subunit, not only is stream underscored, but the actual result
-        # object is hidden inside a wrapper decorator, get out the real stream
-        if stream is None:
-            stream = result.decorated._stream
-        stored_count = 0
-        from bzrlib.tests import selftest_debug_flags
-        notify = "collection" in selftest_debug_flags
         while tests:
             if result.shouldStop:
                 self._tests = reversed(tests)
                 break
-            case = _run_and_collect_case(tests.pop(), result)()
-            new_stored_count = getattr(result, "_count_stored_tests", int)()
-            if case is not None and isinstance(case, unittest.TestCase):
-                if stored_count == new_stored_count and notify:
-                    # Testcase didn't fail, but somehow is still alive
-                    stream.write("Uncollected test case: %s\n" % (case.id(),))
-                # Zombie the testcase but leave a working stub id method
-                case.__dict__ = {"id": lambda _id=case.id(): _id}
-            stored_count = new_stored_count
+            tests.pop().run(result)
         return result
 
 
-def _run_and_collect_case(case, res):
-    """Run test case against result and use weakref to drop the refcount"""
-    case.run(res)
-    return weakref.ref(case)
-
-
 class TestLoader(unittest.TestLoader):
     """Custom TestLoader to extend the stock python one."""
 

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/__init__.py	2011-05-19 18:39:39 +0000
@@ -492,10 +492,6 @@
         self.not_applicable_count += 1
         self.report_not_applicable(test, reason)
 
-    def _count_stored_tests(self):
-        """Count of tests instances kept alive due to not succeeding"""
-        return self.error_count + self.failure_count + self.known_failure_count
-
     def _post_mortem(self, tb=None):
         """Start a PDB post mortem session."""
         if os.environ.get('BZR_TEST_PDB', None):
@@ -3064,9 +3060,6 @@
                             result_decorators=result_decorators,
                             )
     runner.stop_on_failure=stop_on_failure
-    if isinstance(suite, unittest.TestSuite):
-        # Empty out _tests list of passed suite and populate new TestSuite
-        suite._tests[:], suite = [], TestSuite(suite)
     # built in decorator factories:
     decorators = [
         random_order(random_seed, runner),
@@ -3170,17 +3163,34 @@
 
 class TestDecorator(TestUtil.TestSuite):
     """A decorator for TestCase/TestSuite objects.
-
-    Contains rather than flattening suite passed on construction
+    
+    Usually, subclasses should override __iter__(used when flattening test
+    suites), which we do to filter, reorder, parallelise and so on, run() and
+    debug().
     """
 
-    def __init__(self, suite=None):
-        super(TestDecorator, self).__init__()
-        if suite is not None:
-            self.addTest(suite)
-
-    # Don't need subclass run method with suite emptying
-    run = unittest.TestSuite.run
+    def __init__(self, suite):
+        TestUtil.TestSuite.__init__(self)
+        self.addTest(suite)
+
+    def countTestCases(self):
+        cases = 0
+        for test in self:
+            cases += test.countTestCases()
+        return cases
+
+    def debug(self):
+        for test in self:
+            test.debug()
+
+    def run(self, result):
+        # Use iteration on self, not self._tests, to allow subclasses to hook
+        # into __iter__.
+        for test in self:
+            if result.shouldStop:
+                break
+            test.run(result)
+        return result
 
 
 class CountingDecorator(TestDecorator):
@@ -3197,50 +3207,90 @@
     """A decorator which excludes test matching an exclude pattern."""
 
     def __init__(self, suite, exclude_pattern):
-        super(ExcludeDecorator, self).__init__(
-            exclude_tests_by_re(suite, exclude_pattern))
+        TestDecorator.__init__(self, suite)
+        self.exclude_pattern = exclude_pattern
+        self.excluded = False
+
+    def __iter__(self):
+        if self.excluded:
+            return iter(self._tests)
+        self.excluded = True
+        suite = exclude_tests_by_re(self, self.exclude_pattern)
+        del self._tests[:]
+        self.addTests(suite)
+        return iter(self._tests)
 
 
 class FilterTestsDecorator(TestDecorator):
     """A decorator which filters tests to those matching a pattern."""
 
     def __init__(self, suite, pattern):
-        super(FilterTestsDecorator, self).__init__(
-            filter_suite_by_re(suite, pattern))
+        TestDecorator.__init__(self, suite)
+        self.pattern = pattern
+        self.filtered = False
+
+    def __iter__(self):
+        if self.filtered:
+            return iter(self._tests)
+        self.filtered = True
+        suite = filter_suite_by_re(self, self.pattern)
+        del self._tests[:]
+        self.addTests(suite)
+        return iter(self._tests)
 
 
 class RandomDecorator(TestDecorator):
     """A decorator which randomises the order of its tests."""
 
     def __init__(self, suite, random_seed, stream):
-        random_seed = self.actual_seed(random_seed)
-        stream.write("Randomizing test order using seed %s\n\n" %
-            (random_seed,))
+        TestDecorator.__init__(self, suite)
+        self.random_seed = random_seed
+        self.randomised = False
+        self.stream = stream
+
+    def __iter__(self):
+        if self.randomised:
+            return iter(self._tests)
+        self.randomised = True
+        self.stream.write("Randomizing test order using seed %s\n\n" %
+            (self.actual_seed()))
         # Initialise the random number generator.
-        random.seed(random_seed)
-        super(RandomDecorator, self).__init__(randomize_suite(suite))
+        random.seed(self.actual_seed())
+        suite = randomize_suite(self)
+        del self._tests[:]
+        self.addTests(suite)
+        return iter(self._tests)
 
-    @staticmethod
-    def actual_seed(seed):
-        if seed == "now":
+    def actual_seed(self):
+        if self.random_seed == "now":
             # We convert the seed to a long to make it reuseable across
             # invocations (because the user can reenter it).
-            return long(time.time())
+            self.random_seed = long(time.time())
         else:
             # Convert the seed to a long if we can
             try:
-                return long(seed)
-            except (TypeError, ValueError):
+                self.random_seed = long(self.random_seed)
+            except:
                 pass
-        return seed
+        return self.random_seed
 
 
 class TestFirstDecorator(TestDecorator):
     """A decorator which moves named tests to the front."""
 
     def __init__(self, suite, pattern):
-        super(TestFirstDecorator, self).__init__()
-        self.addTests(split_suite_by_re(suite, pattern))
+        TestDecorator.__init__(self, suite)
+        self.pattern = pattern
+        self.filtered = False
+
+    def __iter__(self):
+        if self.filtered:
+            return iter(self._tests)
+        self.filtered = True
+        suites = split_suite_by_re(self, self.pattern)
+        del self._tests[:]
+        self.addTests(suites)
+        return iter(self._tests)
 
 
 def partition_tests(suite, count):
@@ -3293,10 +3343,9 @@
                 os.waitpid(self.pid, 0)
 
     test_blocks = partition_tests(suite, concurrency)
-    suite._tests[:] = []
     for process_tests in test_blocks:
-        process_suite = TestUtil.TestSuite(process_tests)
-        process_tests[:] = []
+        process_suite = TestUtil.TestSuite()
+        process_suite.addTests(process_tests)
         c2pread, c2pwrite = os.pipe()
         pid = os.fork()
         if pid == 0:
@@ -3426,8 +3475,6 @@
 #                           with proper exclusion rules.
 #   -Ethreads               Will display thread ident at creation/join time to
 #                           help track thread leaks
-#   -Ecollection            Display the identity of any test cases that weren't
-#                           deallocated after being completed.
 selftest_debug_flags = set()
 
 

=== modified file 'bzrlib/tests/blackbox/test_breakin.py'
--- a/bzrlib/tests/blackbox/test_breakin.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/blackbox/test_breakin.py	2011-05-19 18:39:39 +0000
@@ -42,6 +42,10 @@
     def setUp(self):
         super(TestBreakin, self).setUp()
         self.requireFeature(tests.BreakinFeature)
+        if sys.platform == 'win32':
+            self._send_signal = self._send_signal_win32
+        else:
+            self._send_signal = self._send_signal_via_kill
 
     def _send_signal_via_kill(self, pid, sig_type):
         if sig_type == 'break':
@@ -85,11 +89,6 @@
             exit_code = breakin.determine_signal()
             ctypes.windll.kernel32.TerminateProcess(pid, exit_code)
 
-    if sys.platform == 'win32':
-        _send_signal = _send_signal_win32
-    else:
-        _send_signal = _send_signal_via_kill
-
     def _popen(self, *args, **kwargs):
         if sys.platform == 'win32':
             CREATE_NEW_PROCESS_GROUP = 512

=== modified file 'bzrlib/tests/blackbox/test_exceptions.py'
--- a/bzrlib/tests/blackbox/test_exceptions.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/blackbox/test_exceptions.py	2011-05-19 18:39:39 +0000
@@ -123,7 +123,7 @@
             check = self.assertContainsRe
         else:
             check = self.assertNotContainsRe
-        check(self.get_log(), 'WARNING.*bzr upgrade')
+        check(self._get_log(keep_log_file=True), 'WARNING.*bzr upgrade')
 
     def test_repository_deprecation_warning(self):
         """Old formats give a warning"""

=== modified file 'bzrlib/tests/blackbox/test_log.py'
--- a/bzrlib/tests/blackbox/test_log.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/blackbox/test_log.py	2011-05-19 18:39:39 +0000
@@ -75,8 +75,6 @@
                 self.log_catcher = test_log.LogCatcher(*args, **kwargs)
                 # Always return our own log formatter
                 return self.log_catcher
-        # Break cycle with closure over self on cleanup by removing method
-        self.addCleanup(setattr, MyLogFormatter, "__new__", None)
 
         def getme(branch):
                 # Always return our own log formatter class hijacking the

=== modified file 'bzrlib/tests/blackbox/test_serve.py'
--- a/bzrlib/tests/blackbox/test_serve.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/blackbox/test_serve.py	2011-05-19 18:39:39 +0000
@@ -274,8 +274,7 @@
 
 class TestUserdirExpansion(TestCaseWithMemoryTransport):
 
-    @staticmethod
-    def fake_expanduser(path):
+    def fake_expanduser(self, path):
         """A simple, environment-independent, function for the duration of this
         test.
 

=== modified file 'bzrlib/tests/per_repository_vf/test_check.py'
--- a/bzrlib/tests/per_repository_vf/test_check.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/per_repository_vf/test_check.py	2011-05-19 18:39:39 +0000
@@ -104,8 +104,8 @@
             needed_refs.setdefault(ref, []).append(tree.branch)
         self.tree_check = tree._check
         self.branch_check = tree.branch.check
-        self.overrideAttr(tree, "_check", self.tree_callback)
-        self.overrideAttr(tree.branch, "check", self.branch_callback)
+        tree._check = self.tree_callback
+        tree.branch.check = self.branch_callback
         self.callbacks = []
         tree.branch.repository.check([revid], callback_refs=needed_refs)
         self.assertNotEqual([], self.callbacks)

=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/test_chk_map.py	2011-05-19 18:39:39 +0000
@@ -1108,7 +1108,7 @@
         basis_get = basis._store.get_record_stream
         def get_record_stream(keys, order, fulltext):
             if ('sha1:1adf7c0d1b9140ab5f33bb64c6275fa78b1580b7',) in keys:
-                raise AssertionError("'aaa' pointer was followed %r" % keys)
+                self.fail("'aaa' pointer was followed %r" % keys)
             return basis_get(keys, order, fulltext)
         basis._store.get_record_stream = get_record_stream
         result = sorted(list(target.iter_changes(basis)))

=== modified file 'bzrlib/tests/test_clean_tree.py'
--- a/bzrlib/tests/test_clean_tree.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/test_clean_tree.py	2011-05-19 18:39:39 +0000
@@ -98,6 +98,7 @@
         def _dummy_rmtree(path, ignore_errors=False, onerror=None):
             """Call user supplied error handler onerror.
             """
+            self.assertTrue(isinstance(onerror, types.FunctionType))
             # Indicate failure in removing 'path' if path is subdir0
             # We later check to ensure that this is indicated
             # to the user as a warning. We raise OSError to construct

=== modified file 'bzrlib/tests/test_http.py'
--- a/bzrlib/tests/test_http.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/test_http.py	2011-05-19 18:39:39 +0000
@@ -2013,12 +2013,11 @@
         tests.TestCase.setUp(self)
         self.server = self._activity_server(self._protocol_version)
         self.server.start_server()
-        _activities = {} # Don't close over self and create a cycle
+        self.activities = {}
         def report_activity(t, bytes, direction):
-            count = _activities.get(direction, 0)
+            count = self.activities.get(direction, 0)
             count += bytes
-            _activities[direction] = count
-        self.activities = _activities
+            self.activities[direction] = count
 
         # We override at class level because constructors may propagate the
         # bound method and render instance overriding ineffective (an

=== modified file 'bzrlib/tests/test_merge.py'
--- a/bzrlib/tests/test_merge.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/test_merge.py	2011-05-19 18:39:39 +0000
@@ -2863,14 +2863,14 @@
 
     def get_merger_factory(self):
         # Allows  the inner methods to access the test attributes
-        calls = self.calls
+        test = self
 
         class FooMerger(_mod_merge.ConfigurableFileMerger):
             name_prefix = "foo"
             default_files = ['bar']
 
             def merge_text(self, params):
-                calls.append('merge_text')
+                test.calls.append('merge_text')
                 return ('not_applicable', None)
 
         def factory(merger):

=== modified file 'bzrlib/tests/test_registry.py'
--- a/bzrlib/tests/test_registry.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/test_registry.py	2011-05-19 18:39:39 +0000
@@ -215,13 +215,11 @@
         # We create a registry with "official" objects and "hidden"
         # objects. The later represent the side effects that led to bug #277048
         # and #430510
-        _registry = registry.Registry()
+        self.registry =  registry.Registry()
 
         def register_more():
-           _registry.register('hidden', None)
+            self.registry.register('hidden', None)
 
-        # Avoid closing over self by binding local variable
-        self.registry = _registry
         self.registry.register('passive', None)
         self.registry.register('active', register_more)
         self.registry.register('passive-too', None)
@@ -231,7 +229,7 @@
             def get_obj(inner_self):
                 # Surprise ! Getting a registered object (think lazy loaded
                 # module) register yet another object !
-                _registry.register('more hidden', None)
+                self.registry.register('more hidden', None)
                 return inner_self._obj
 
         self.registry.register('hacky', None)

=== modified file 'bzrlib/tests/test_repository.py'
--- a/bzrlib/tests/test_repository.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/test_repository.py	2011-05-19 18:39:39 +0000
@@ -1602,7 +1602,7 @@
         self.addCleanup(target.unlock)
         source = source_tree.branch.repository._get_source(target._format)
         self.orig_pack = target.pack
-        self.overrideAttr(target, "pack", self.log_pack)
+        target.pack = self.log_pack
         search = target.search_missing_revision_ids(
             source_tree.branch.repository, revision_ids=[tip])
         stream = source.get_stream(search)
@@ -1626,7 +1626,7 @@
         self.addCleanup(target.unlock)
         source = source_tree.branch.repository
         self.orig_pack = target.pack
-        self.overrideAttr(target, "pack", self.log_pack)
+        target.pack = self.log_pack
         target.fetch(source)
         if expect_pack_called:
             self.assertLength(1, self.calls)

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/test_selftest.py	2011-05-19 18:39:39 +0000
@@ -17,7 +17,6 @@
 """Tests for the test framework."""
 
 from cStringIO import StringIO
-import gc
 import doctest
 import os
 import signal
@@ -37,7 +36,7 @@
     DocTestMatches,
     Equals,
     )
-import testtools.testresult.doubles
+import testtools.tests.helpers
 
 import bzrlib
 from bzrlib import (
@@ -722,7 +721,7 @@
 
     def test_profiles_tests(self):
         self.requireFeature(test_lsprof.LSProfFeature)
-        terminal = testtools.testresult.doubles.ExtendedTestResult()
+        terminal = testtools.tests.helpers.ExtendedTestResult()
         result = tests.ProfileResult(terminal)
         class Sample(tests.TestCase):
             def a(self):
@@ -745,7 +744,7 @@
                 descriptions=0,
                 verbosity=1,
                 )
-        capture = testtools.testresult.doubles.ExtendedTestResult()
+        capture = testtools.tests.helpers.ExtendedTestResult()
         test_case.run(MultiTestResult(result, capture))
         run_case = capture._events[0][1]
         timed_string = result._testTimeString(run_case)
@@ -1046,7 +1045,7 @@
         test = unittest.TestSuite()
         test.addTest(Test("known_failure_test"))
         def failing_test():
-            raise AssertionError('foo')
+            self.fail('foo')
         test.addTest(unittest.FunctionTestCase(failing_test))
         stream = StringIO()
         runner = tests.TextTestRunner(stream=stream)
@@ -1060,7 +1059,7 @@
             '^----------------------------------------------------------------------\n'
             'Traceback \\(most recent call last\\):\n'
             '  .*' # File .*, line .*, in failing_test' - but maybe not from .pyc
-            '    raise AssertionError\\(\'foo\'\\)\n'
+            '    self.fail\\(\'foo\'\\)\n'
             '.*'
             '^----------------------------------------------------------------------\n'
             '.*'
@@ -1072,7 +1071,7 @@
         # the final output.
         class Test(tests.TestCase):
             def known_failure_test(self):
-                self.knownFailure("Never works...")
+                self.expectFailure('failed', self.assertTrue, False)
         test = Test("known_failure_test")
         stream = StringIO()
         runner = tests.TextTestRunner(stream=stream)
@@ -2038,17 +2037,17 @@
 
     def test_lsprof_tests(self):
         self.requireFeature(test_lsprof.LSProfFeature)
-        results = []
+        calls = []
         class Test(object):
             def __call__(test, result):
                 test.run(result)
             def run(test, result):
-                results.append(result)
+                self.assertIsInstance(result, ExtendedToOriginalDecorator)
+                calls.append("called")
             def countTestCases(self):
                 return 1
         self.run_selftest(test_suite_factory=Test, lsprof_tests=True)
-        self.assertLength(1, results)
-        self.assertIsInstance(results.pop(), ExtendedToOriginalDecorator)
+        self.assertLength(1, calls)
 
     def test_random(self):
         # test randomising by listing a number of tests.
@@ -3380,78 +3379,6 @@
         self.assertLength(1, calls)
 
 
-class TestUncollectedWarnings(tests.TestCase):
-    """Check a test case still alive after being run emits a warning"""
-
-    class Test(tests.TestCase):
-        def test_pass(self):
-            pass
-        def test_self_ref(self):
-            self.also_self = self.test_self_ref
-        def test_skip(self):
-            self.skip("Don't need")
-
-    def _get_suite(self):
-        return TestUtil.TestSuite([
-            self.Test("test_pass"),
-            self.Test("test_self_ref"),
-            self.Test("test_skip"),
-            ])
-
-    def _run_selftest_with_suite(self, **kwargs):
-        sio = StringIO()
-        gc_on = gc.isenabled()
-        if gc_on:
-            gc.disable()
-        try:
-            tests.selftest(test_suite_factory=self._get_suite, stream=sio,
-                **kwargs)
-        finally:
-            if gc_on:
-                gc.enable()
-        output = sio.getvalue()
-        self.assertNotContainsRe(output, "Uncollected test case.*test_pass")
-        self.assertContainsRe(output, "Uncollected test case.*test_self_ref")
-        return output
-
-    def test_testsuite(self):
-        self._run_selftest_with_suite()
-
-    def test_pattern(self):
-        out = self._run_selftest_with_suite(pattern="test_(?:pass|self_ref)$")
-        self.assertNotContainsRe(out, "test_skip")
-
-    def test_exclude_pattern(self):
-        out = self._run_selftest_with_suite(exclude_pattern="test_skip$")
-        self.assertNotContainsRe(out, "test_skip")
-
-    def test_random_seed(self):
-        self._run_selftest_with_suite(random_seed="now")
-
-    def test_matching_tests_first(self):
-        self._run_selftest_with_suite(matching_tests_first=True,
-            pattern="test_self_ref$")
-
-    def test_starting_with_and_exclude(self):
-        out = self._run_selftest_with_suite(starting_with=["bt."],
-            exclude_pattern="test_skip$")
-        self.assertNotContainsRe(out, "test_skip")
-
-    def test_additonal_decorator(self):
-        out = self._run_selftest_with_suite(
-            suite_decorators=[tests.TestDecorator])
-
-
-class TestUncollectedWarningsSubunit(TestUncollectedWarnings):
-    """Check warnings from tests staying alive are emitted with subunit"""
-
-    _test_needs_features = [features.subunit]
-
-    def _run_selftest_with_suite(self, **kwargs):
-        return TestUncollectedWarnings._run_selftest_with_suite(self,
-            runner_class=tests.SubUnitBzrRunner, **kwargs)
-
-
 class TestEnvironHandling(tests.TestCase):
 
     def test_overrideEnv_None_called_twice_doesnt_leak(self):

=== modified file 'bzrlib/tests/test_smart.py'
--- a/bzrlib/tests/test_smart.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/test_smart.py	2011-05-19 18:39:39 +0000
@@ -99,7 +99,7 @@
         # the default or a parameterized class, but rather use the
         # TestCaseWithTransport infrastructure to set up a smart server and
         # transport.
-        self.overrideAttr(self, "transport_server", self.make_transport_server)
+        self.transport_server = self.make_transport_server
 
     def make_transport_server(self):
         return test_server.SmartTCPServer_for_testing('-' + self.id())

=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/test_smart_transport.py	2011-05-19 18:39:39 +0000
@@ -1493,7 +1493,6 @@
         smart_protocol._has_dispatched = True
         smart_protocol.request = _mod_request.SmartServerRequestHandler(
             None, _mod_request.request_handlers, '/')
-        # GZ 2010-08-10: Cycle with closure affects 4 tests
         class FakeCommand(_mod_request.SmartServerRequest):
             def do_body(self_cmd, body_bytes):
                 self.end_received = True

=== modified file 'bzrlib/tests/test_workingtree_4.py'
--- a/bzrlib/tests/test_workingtree_4.py	2011-05-19 18:26:56 +0000
+++ b/bzrlib/tests/test_workingtree_4.py	2011-05-19 18:39:39 +0000
@@ -174,9 +174,9 @@
         # it's given; any calls to forbidden methods will raise an
         # AssertionError
         repo = tree.branch.repository
-        self.overrideAttr(repo, "get_revision", self.fail)
-        self.overrideAttr(repo, "get_inventory", self.fail)
-        self.overrideAttr(repo, "_get_inventory_xml", self.fail)
+        repo.get_revision = self.fail
+        repo.get_inventory = self.fail
+        repo._get_inventory_xml = self.fail
         # try to set the parent trees.
         tree.set_parent_trees([(rev1, rev1_tree)])
 
@@ -214,8 +214,8 @@
         # answer 'get_parent_ids' for the revision tree- dirstate does not
         # cache the parents of a parent tree at this point.
         #repo.get_revision = self.fail
-        self.overrideAttr(repo, "get_inventory", self.fail)
-        self.overrideAttr(repo, "_get_inventory_xml", self.fail)
+        repo.get_inventory = self.fail
+        repo._get_inventory_xml = self.fail
         # set the parent trees.
         tree.set_parent_trees([(rev1, rev1_tree), (rev2, rev2_tree)])
         # read the first tree



More information about the bazaar-commits mailing list