From 4bc9016b2bb93a695491cd765d72c13d1c9a2c1a Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 1 Sep 2019 19:17:02 +0200 Subject: [PATCH] Handle --fulltrace with pytest.raises This changes `_repr_failure_py` to use `tbfilter=False` always. --- src/_pytest/nodes.py | 4 +--- testing/code/test_excinfo.py | 7 +++++++ 2 files changed, 8 insertions(+), 3 deletions(-) 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: