Further "unknown marks warning" improvements (#5178)
Further "unknown marks warning" improvements
This commit is contained in:
@@ -47,11 +47,6 @@ def pytest_addoption(parser):
|
||||
type="args",
|
||||
default=[],
|
||||
)
|
||||
# parser.addini("dirpatterns",
|
||||
# "patterns specifying possible locations of test files",
|
||||
# type="linelist", default=["**/test_*.txt",
|
||||
# "**/test_*.py", "**/*_test.py"]
|
||||
# )
|
||||
group = parser.getgroup("general", "running and selection options")
|
||||
group._addoption(
|
||||
"-x",
|
||||
@@ -71,9 +66,10 @@ def pytest_addoption(parser):
|
||||
help="exit after first num failures or errors.",
|
||||
)
|
||||
group._addoption(
|
||||
"--strict-markers",
|
||||
"--strict",
|
||||
action="store_true",
|
||||
help="marks not registered in configuration file raise errors.",
|
||||
help="markers not registered in the `markers` section of the configuration file raise errors.",
|
||||
)
|
||||
group._addoption(
|
||||
"-c",
|
||||
|
||||
@@ -311,8 +311,11 @@ class MarkGenerator(object):
|
||||
# If the name is not in the set of known marks after updating,
|
||||
# then it really is time to issue a warning or an error.
|
||||
if name not in self._markers:
|
||||
if self._config.option.strict:
|
||||
fail("{!r} is not a registered marker".format(name), pytrace=False)
|
||||
if self._config.option.strict_markers:
|
||||
fail(
|
||||
"{!r} not found in `markers` configuration option".format(name),
|
||||
pytrace=False,
|
||||
)
|
||||
else:
|
||||
warnings.warn(
|
||||
"Unknown pytest.mark.%s - is this a typo? You can register "
|
||||
|
||||
Reference in New Issue
Block a user