/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Robert Collins
  • Date: 2009-04-08 13:35:12 UTC
  • mto: (4276.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4277.
  • Revision ID: robertc@robertcollins.net-20090408133512-gcnz9qi50rtpnkxk
Move thread leak reporting to ExtendedTestResult.

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
            self.stream.write('tests passed\n')
178
178
        else:
179
179
            self.stream.write('tests failed\n')
 
180
        if TestCase._first_thread_leaker_id:
 
181
            self.stream.write(
 
182
                '%s is leaking threads among %d leaking tests.\n' % (
 
183
                TestCase._first_thread_leaker_id,
 
184
                TestCase._leaking_threads_tests))
180
185
 
181
186
    def _extractBenchmarkTime(self, testCase):
182
187
        """Add a benchmark time for the current test case."""
745
750
        return password
746
751
 
747
752
 
748
 
def _report_leaked_threads():
749
 
    bzrlib.trace.warning('%s is leaking threads among %d leaking tests',
750
 
                         TestCase._first_thread_leaker_id,
751
 
                         TestCase._leaking_threads_tests)
752
 
 
753
 
 
754
753
class TestCase(unittest.TestCase):
755
754
    """Base class for bzr unit tests.
756
755
 
816
815
            TestCase._leaking_threads_tests += 1
817
816
            if TestCase._first_thread_leaker_id is None:
818
817
                TestCase._first_thread_leaker_id = self.id()
819
 
                # we're not specifically told when all tests are finished.
820
 
                # This will do. We use a function to avoid keeping a reference
821
 
                # to a TestCase object.
822
 
                atexit.register(_report_leaked_threads)
823
818
 
824
819
    def _clear_debug_flags(self):
825
820
        """Prevent externally set debug flags affecting tests.