Skip to content

Commit

Permalink
Handle --fulltrace with pytest.raises
Browse files Browse the repository at this point in the history
This changes `_repr_failure_py` to use `tbfilter=False` always.
  • Loading branch information
blueyed committed Sep 1, 2019
1 parent 8c8809e commit 4bc9016
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/_pytest/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,13 @@ def _repr_failure_py(self, excinfo, style=None):
fm = self.session._fixturemanager
if excinfo.errisinstance(fm.FixtureLookupError):
return excinfo.value.formatrepr()
tbfilter = True
if self.config.getoption("fulltrace", False):
style = "long"
else:
tb = _pytest._code.Traceback([excinfo.traceback[-1]])
self._prunetraceback(excinfo)
if len(excinfo.traceback) == 0:
excinfo.traceback = tb
tbfilter = False # prunetraceback already does it
if style == "auto":
style = "long"
# XXX should excinfo.getrepr record all data and toterminal() process it?
Expand All @@ -279,7 +277,7 @@ def _repr_failure_py(self, excinfo, style=None):
abspath=abspath,
showlocals=self.config.getoption("showlocals", False),
style=style,
tbfilter=tbfilter,
tbfilter=False,
truncate_locals=truncate_locals,
)

Expand Down
7 changes: 7 additions & 0 deletions testing/code/test_excinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@ def test_division_zero():
result = testdir.runpytest()
assert result.ret != 0
result.stdout.fnmatch_lines(["*AssertionError*Pattern*[123]*not found*"])
assert "__tracebackhide__ = True" not in result.stdout.str()

result = testdir.runpytest("--fulltrace")
assert result.ret != 0
result.stdout.fnmatch_lines(
["*__tracebackhide__ = True*", "*AssertionError*Pattern*[123]*not found*"]
)


class TestFormattedExcinfo:
Expand Down

0 comments on commit 4bc9016

Please sign in to comment.