From 0440750144a1f727830c24411cb62b14df7c4cf7 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 19 Nov 2019 16:10:05 +0100 Subject: [PATCH] Display traceback with --strict-markers error --- changelog/6232.improvement.rst | 1 + src/_pytest/mark/structures.py | 2 +- testing/test_mark.py | 12 +++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 changelog/6232.improvement.rst diff --git a/changelog/6232.improvement.rst b/changelog/6232.improvement.rst new file mode 100644 index 00000000000..e3088262ed4 --- /dev/null +++ b/changelog/6232.improvement.rst @@ -0,0 +1 @@ +Display traceback / error location with errors from ``--strict-markers``. diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 18ebc506abb..a464bebee83 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -310,9 +310,9 @@ def __getattr__(self, name: str) -> MarkDecorator: # then it really is time to issue a warning or an error. if name not in self._markers: if self._config.option.strict_markers: + __tracebackhide__ = True fail( "{!r} not found in `markers` configuration option".format(name), - pytrace=False, ) else: warnings.warn( diff --git a/testing/test_mark.py b/testing/test_mark.py index 0e44220259c..50fecfc066c 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -192,7 +192,17 @@ def test_hello(): result = testdir.runpytest(option_name) assert result.ret != 0 result.stdout.fnmatch_lines( - ["'unregisteredmark' not found in `markers` configuration option"] + [ + "collected 0 items / 1 error", + "", + "*= ERRORS =*", + "*_ ERROR collecting test_strict_prohibits_unregistered_markers.py _*", + "test_strict_prohibits_unregistered_markers.py:2: in ", + " @pytest.mark.unregisteredmark", + "E Failed: 'unregisteredmark' not found in `markers` configuration option", + "*! Interrupted: 1 error during collection !*", + "*= 1 error in *", + ] )