Skip to content

Commit 702acdb

Browse files
authored
Merge pull request #5811 from blueyed/fulltrace-pytest-raises
Handle --fulltrace with pytest.raises
2 parents 9422e10 + f832ac3 commit 702acdb

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

changelog/5811.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Handle ``--fulltrace`` correctly with ``pytest.raises``.

src/_pytest/nodes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,13 @@ def _repr_failure_py(self, excinfo, style=None):
245245
fm = self.session._fixturemanager
246246
if excinfo.errisinstance(fm.FixtureLookupError):
247247
return excinfo.value.formatrepr()
248-
tbfilter = True
249248
if self.config.getoption("fulltrace", False):
250249
style = "long"
251250
else:
252251
tb = _pytest._code.Traceback([excinfo.traceback[-1]])
253252
self._prunetraceback(excinfo)
254253
if len(excinfo.traceback) == 0:
255254
excinfo.traceback = tb
256-
tbfilter = False # prunetraceback already does it
257255
if style == "auto":
258256
style = "long"
259257
# XXX should excinfo.getrepr record all data and toterminal() process it?
@@ -279,7 +277,7 @@ def _repr_failure_py(self, excinfo, style=None):
279277
abspath=abspath,
280278
showlocals=self.config.getoption("showlocals", False),
281279
style=style,
282-
tbfilter=tbfilter,
280+
tbfilter=False, # pruned already, or in --fulltrace mode.
283281
truncate_locals=truncate_locals,
284282
)
285283

testing/code/test_excinfo.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,13 @@ def test_division_zero():
399399
result = testdir.runpytest()
400400
assert result.ret != 0
401401
result.stdout.fnmatch_lines(["*AssertionError*Pattern*[123]*not found*"])
402+
assert "__tracebackhide__ = True" not in result.stdout.str()
403+
404+
result = testdir.runpytest("--fulltrace")
405+
assert result.ret != 0
406+
result.stdout.fnmatch_lines(
407+
["*__tracebackhide__ = True*", "*AssertionError*Pattern*[123]*not found*"]
408+
)
402409

403410

404411
class TestFormattedExcinfo:

0 commit comments

Comments
 (0)