Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/6232.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Display traceback / error location with errors from ``--strict-markers``.
2 changes: 1 addition & 1 deletion src/_pytest/mark/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 11 additions & 1 deletion testing/test_mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <module>",
" @pytest.mark.unregisteredmark",
"E Failed: 'unregisteredmark' not found in `markers` configuration option",
"*! Interrupted: 1 error during collection !*",
"*= 1 error in *",
]
)


Expand Down