traceback filtering of non-contiguous unittest frames is broken
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
testtools |
Triaged
|
High
|
Robert Collins |
Bug Description
When an AssertionError is thrown during the fixture set up, then _count_
To reproduce:
Here I have two tests with wrong fixtures. One raises a ZeroDivisionError and the other one an AssertionError
import fixtures
import testtools
class WrongFixtureWit
def setUp(self):
super(
raise AssertionError(
class WrongFixtureWit
def setUp(self):
super(
1/0
class TestCase(
def test_without_
def test_with_
When I run them, I get:
=======
ERROR: test_with_trace (test.TestCase)
-------
_StringException: Traceback (most recent call last):
File "/tmp/test.py", line 22, in test_with_trace
self.
File "/usr/lib/
fixture.setUp()
File "/tmp/test.py", line 13, in setUp
1/0
ZeroDivisionError: integer division or modulo by zero
=======
FAIL: test_without_trace (test.TestCase)
-------
_StringException: Traceback (most recent call last):
File "/tmp/test.py", line 19, in test_without_trace
self.
AssertionError: error
-------
Ran 2 tests in 5.854s
FAILED (failures=1, errors=1)
Note on the second test that there is only one line of the trace, hiding where and why the error occured.
Changed in testtools: | |
status: | New → Confirmed |
description: | updated |
summary: |
- useFixture hides the trace when the fixture throws an AssertionError on - setUp + traceback filtering of non-contiguous unittest frames is broken |
Changed in testtools: | |
assignee: | nobody → Robert Collins (lifeless) |
milestone: | none → next |
Changed in testtools: | |
milestone: | 0.9.32 → none |
I breakpointed _count_ relevant_ tb_levels which interestingly is only hit from the failing case.
The issue is that self.useFixture shows up as a unittest method - which arguably it isn't. But we should show one more frame than we do. -> off by one error?