Also emit PytestUnknownMarkWarning
for unknown marks given in -m
#12166
Labels
topic: marks
related to marks, either the general marks or builtin
If we use
@pytest.mark
with a mark that does not exist, pytest warns about it:results in:
This is to avoid silent failures, e.g. a test being marked
onne
and then never being executed.However, a similar issue exists with
-m
too! If, with the code above, we usepytest -m onne
, that results in:Thanks to exit code 5 (
ExitCode.NO_TESTS_COLLECTED
), this can still be spotted, more or less. However, when using e.g.pytest -m "slow or onne"
, it's not trivially visible anymore that a typo was made (assuming that some tests run due to theslow
mark, of course).Is there a good reason to not validate all marks passed into
-m
against the list of registered marks as well? Have we had an issue about this before? This gets pointed out every once in a while by participants in my pytest trainings, and I feel like I must have reported it before, but I can't seem to find anything.The text was updated successfully, but these errors were encountered: