RemotedTestCase.addCleanup exists but fails under Python 2.7
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Fix Released
|
Low
|
Martin Packman | ||
subunit |
Invalid
|
Undecided
|
Unassigned |
Bug Description
bzr at one point has this code:
# Only check for thread leaks if the test case supports cleanups
addCleanup = getattr(test, "addCleanup", None)
if addCleanup is not None:
When 'test' is a RemotedTestCase and when run under Python 2.7, this fails, because: RemotedTestCase inherits from unittest.TestCase (and thus inherits the addCleanup method), but does not upcall to TestCase's __init__, so self._cleanups isn't initialised. Even if it did upcall, addCleanup wouldn't be respected because RemotedTestCase completely overrides run. The way this manifests itself is that 'bzr selftest --parallel=fork' hangs almost immediately.
I think the solution is probably to stop inheriting from TestCase: it ought to be enough to simply provide the same interface, and the friction with TestCase's __init__ is too great for RemotedTestCase to sensibly reuse it.
Related branches
- Jelmer Vernooij (community): Approve
-
Diff: 32 lines (+3/-6)2 files modifiedbzrlib/tests/__init__.py (+3/-4)
bzrlib/tests/test_selftest.py (+0/-2)
tags: | added: python27 |
Changed in bzr: | |
milestone: | none → 2.3b5 |
status: | In Progress → Fix Released |
On Tue, Sep 14, 2010 at 12:05 PM, Andrew Bennetts self._check_ leaked_ threads, test)
<email address hidden> wrote:
> Public bug reported:
>
> bzr at one point has this code:
>
> # Only check for thread leaks if the test case supports cleanups
> addCleanup = getattr(test, "addCleanup", None)
> if addCleanup is not None:
> addCleanup(
Thats buggy code though.