Rev 4273: Move thread leak reporting to ExtendedTestResult. in http://people.ubuntu.com/~robertc/baz2.0/pending/tests.result_does_output

Robert Collins robertc at robertcollins.net
Wed Apr 8 14:35:16 BST 2009


At http://people.ubuntu.com/~robertc/baz2.0/pending/tests.result_does_output

------------------------------------------------------------
revno: 4273
revision-id: robertc at robertcollins.net-20090408133512-gcnz9qi50rtpnkxk
parent: robertc at robertcollins.net-20090408132900-0wvutu89y32oyov3
committer: Robert Collins <robertc at robertcollins.net>
branch nick: tests.result_does_output
timestamp: Wed 2009-04-08 23:35:12 +1000
message:
  Move thread leak reporting to ExtendedTestResult.
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-04-08 13:29:00 +0000
+++ b/bzrlib/tests/__init__.py	2009-04-08 13:35:12 +0000
@@ -177,6 +177,11 @@
             self.stream.write('tests passed\n')
         else:
             self.stream.write('tests failed\n')
+        if TestCase._first_thread_leaker_id:
+            self.stream.write(
+                '%s is leaking threads among %d leaking tests.\n' % (
+                TestCase._first_thread_leaker_id,
+                TestCase._leaking_threads_tests))
 
     def _extractBenchmarkTime(self, testCase):
         """Add a benchmark time for the current test case."""
@@ -745,12 +750,6 @@
         return password
 
 
-def _report_leaked_threads():
-    bzrlib.trace.warning('%s is leaking threads among %d leaking tests',
-                         TestCase._first_thread_leaker_id,
-                         TestCase._leaking_threads_tests)
-
-
 class TestCase(unittest.TestCase):
     """Base class for bzr unit tests.
 
@@ -816,10 +815,6 @@
             TestCase._leaking_threads_tests += 1
             if TestCase._first_thread_leaker_id is None:
                 TestCase._first_thread_leaker_id = self.id()
-                # we're not specifically told when all tests are finished.
-                # This will do. We use a function to avoid keeping a reference
-                # to a TestCase object.
-                atexit.register(_report_leaked_threads)
 
     def _clear_debug_flags(self):
         """Prevent externally set debug flags affecting tests.




More information about the bazaar-commits mailing list