Merge lp:~gz/bzr/only_track_threads_on_bzrlib_testcases_637674 into lp:bzr

Proposed by Martin Packman
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 5582
Proposed branch: lp:~gz/bzr/only_track_threads_on_bzrlib_testcases_637674
Merge into: lp:bzr
Diff against target: 32 lines (+3/-6)
2 files modified
bzrlib/tests/__init__.py (+3/-4)
bzrlib/tests/test_selftest.py (+0/-2)
To merge this branch: bzr merge lp:~gz/bzr/only_track_threads_on_bzrlib_testcases_637674
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) Approve
Review via email: mp+44707@code.launchpad.net

Commit message

Only track threads on bzrlib testcases.

Description of the change

When updating the thread leak detection code I was trying to be clever and get it working on non-bzrlib testcases. In practice, this is more likely to break things on Python 2.7 than help, so this branch limits it to case instances derived from our code.

Branch fixes the same two Python 2.7 failures as lp:~jelmer/bzr/super-startTests so should mean that branch doesn't need to be merged.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

That's quite a bit neater than my version. Thanks :-)

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/__init__.py'
2--- bzrlib/tests/__init__.py 2010-12-21 10:48:22 +0000
3+++ bzrlib/tests/__init__.py 2010-12-26 16:29:28 +0000
4@@ -286,10 +286,9 @@
5 addOnException = getattr(test, "addOnException", None)
6 if addOnException is not None:
7 addOnException(self._record_traceback_from_test)
8- # Only check for thread leaks if the test case supports cleanups
9- addCleanup = getattr(test, "addCleanup", None)
10- if addCleanup is not None:
11- addCleanup(self._check_leaked_threads, test)
12+ # Only check for thread leaks on bzrlib derived test cases
13+ if isinstance(test, TestCase):
14+ test.addCleanup(self._check_leaked_threads, test)
15
16 def startTests(self):
17 self.report_tests_starting()
18
19=== modified file 'bzrlib/tests/test_selftest.py'
20--- bzrlib/tests/test_selftest.py 2010-12-16 13:15:42 +0000
21+++ bzrlib/tests/test_selftest.py 2010-12-26 16:29:28 +0000
22@@ -3251,10 +3251,8 @@
23 class Test(unittest.TestCase):
24 def runTest(self):
25 pass
26- addCleanup = None # for when on Python 2.7 with native addCleanup
27 result = self.LeakRecordingResult()
28 test = Test()
29- self.assertIs(getattr(test, "addCleanup", None), None)
30 result.startTestRun()
31 test.run(result)
32 result.stopTestRun()