Rev 4656: Fix interface skew between bzr selftest and python unittest - use stopTestRun not done to end test runs. in http://bazaar.launchpad.net/~lifeless/bzr/test-speed

Robert Collins robertc at robertcollins.net
Wed Aug 26 23:47:27 BST 2009


At http://bazaar.launchpad.net/~lifeless/bzr/test-speed

------------------------------------------------------------
revno: 4656
revision-id: robertc at robertcollins.net-20090826224718-xjqbmhs14m7lmnjg
parent: robertc at robertcollins.net-20090826070245-myz71im24m39vdwc
committer: Robert Collins <robertc at robertcollins.net>
branch nick: test-speed
timestamp: Thu 2009-08-27 08:47:18 +1000
message:
  Fix interface skew between bzr selftest and python unittest - use stopTestRun not done to end test runs.
=== modified file 'NEWS'
--- a/NEWS	2009-08-26 07:02:45 +0000
+++ b/NEWS	2009-08-26 22:47:18 +0000
@@ -79,6 +79,9 @@
   classes changed to manage lock lifetime of the trees they open in a way
   consistent with reader-exclusive locks. (Robert Collins, #305006)
 
+* ``bzrlib.tests`` now uses ``stopTestRun`` for its ``TestResult``
+  subclasses - the same as python's unittest module. (Robert Collins)
+
 Internals
 *********
 

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-08-26 07:02:45 +0000
+++ b/bzrlib/tests/__init__.py	2009-08-26 22:47:18 +0000
@@ -175,9 +175,7 @@
         self._overall_start_time = time.time()
         self._strict = strict
 
-    def done(self):
-        # nb: called stopTestRun in the version of this that Python merged
-        # upstream, according to lifeless 20090803
+    def stopTestRun(self):
         if self._strict:
             ok = self.wasStrictlySuccessful()
         else:
@@ -421,10 +419,10 @@
         self.pb.update_latency = 0
         self.pb.show_transport_activity = False
 
-    def done(self):
+    def stopTestRun(self):
         # called when the tests that are going to run have run
         self.pb.clear()
-        super(TextTestResult, self).done()
+        super(TextTestResult, self).stopTestRun()
 
     def finished(self):
         self.pb.finished()
@@ -2833,7 +2831,7 @@
     result = runner.run(suite)
     if list_only:
         return True
-    result.done()
+    result.stopTestRun()
     if strict:
         return result.wasStrictlySuccessful()
     else:
@@ -3168,6 +3166,12 @@
     def stopTest(self, test):
         self.result.stopTest(test)
 
+    def startTestRun(self):
+        self.result.startTestRun()
+
+    def stopTestRun(self):
+        self.result.stopTest()
+
     def addSkip(self, test, reason):
         self.result.addSkip(test, reason)
 

=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2009-08-26 06:33:13 +0000
+++ b/bzrlib/tests/test_selftest.py	2009-08-26 22:47:18 +0000
@@ -820,7 +820,7 @@
     def test_known_failure(self):
         """A KnownFailure being raised should trigger several result actions."""
         class InstrumentedTestResult(tests.ExtendedTestResult):
-            def done(self): pass
+            def stopTestRun(self): pass
             def startTests(self): pass
             def report_test_start(self, test): pass
             def report_known_failure(self, test, err):
@@ -874,7 +874,7 @@
     def test_add_not_supported(self):
         """Test the behaviour of invoking addNotSupported."""
         class InstrumentedTestResult(tests.ExtendedTestResult):
-            def done(self): pass
+            def stopTestRun(self): pass
             def startTests(self): pass
             def report_test_start(self, test): pass
             def report_unsupported(self, test, feature):
@@ -918,7 +918,7 @@
     def test_unavailable_exception(self):
         """An UnavailableFeature being raised should invoke addNotSupported."""
         class InstrumentedTestResult(tests.ExtendedTestResult):
-            def done(self): pass
+            def stopTestRun(self): pass
             def startTests(self): pass
             def report_test_start(self, test): pass
             def addNotSupported(self, test, feature):
@@ -2935,15 +2935,15 @@
         tests.run_suite(suite, runner_class=MyRunner, stream=StringIO())
         self.assertLength(1, calls)
 
-    def test_done(self):
-        """run_suite should call result.done()"""
+    def test_stopTestRun(self):
+        """run_suite should call result.stopTestRun()"""
         self.calls = 0
         def one_more_call(): self.calls += 1
         def test_function():
             pass
         test = unittest.FunctionTestCase(test_function)
         class InstrumentedTestResult(tests.ExtendedTestResult):
-            def done(self): one_more_call()
+            def stopTestRun(self): one_more_call()
         class MyRunner(tests.TextTestRunner):
             def run(self, test):
                 return InstrumentedTestResult(self.stream, self.descriptions,




More information about the bazaar-commits mailing list