diff --git a/changelog/5811.bugfix.rst b/changelog/5811.bugfix.rst new file mode 100644 index 00000000000..8e3810dad8c --- /dev/null +++ b/changelog/5811.bugfix.rst @@ -0,0 +1 @@ +Handle --fulltrace with pytest.raises. diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 9b78dca38aa..1ad5ec1a995 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -245,7 +245,6 @@ 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: @@ -253,7 +252,6 @@ def _repr_failure_py(self, excinfo, style=None): 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? @@ -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, ) diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index bdd7a5a6f5d..5673b811b98 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -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: