Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit a warning when using an unregistered mark via -m #10514

Open
The-Compiler opened this issue Nov 18, 2022 · 1 comment · May be fixed by #12246
Open

Emit a warning when using an unregistered mark via -m #10514

The-Compiler opened this issue Nov 18, 2022 · 1 comment · May be fixed by #12246
Labels
topic: marks related to marks, either the general marks or builtin type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@The-Compiler
Copy link
Member

In #4826 (and earlier with --strict), we introduced warnings for applying unregistered marks, because otherwise something like:

@pytest.mark.sloww  # sic!
def test_slow():
    pass

would be a silent failure, with the test not being run with -m slow.

However, there is a similar issue when using marks: If you end up e.g. accidentally typing -m "not sloww", this won't actually skip the slow tests, but you might not actually notice that this mark doesn't exist. Similarly, if you do -m "mark1 or mark2_with_typo", it's tricky to recognize that less tests are run than what was actually intended.

IMHO, such usage should raise a warning (or even an error?).

@The-Compiler The-Compiler added type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature topic: marks related to marks, either the general marks or builtin labels Nov 18, 2022
@The-Compiler
Copy link
Member Author

@poulami-sau, from #12166:

I am interested in working on this issue, but I'm having a hard time trying to simulate the conditions, and would appreciate some guidance on this!

Could you be more specific about what's giving you trouble? The easiest way to reproduce this would me -m doesnotexist, where pytest should warn that there is no registered marker with that name (just like when you add @pytest.mark.doesnotexisteither above a test). Currently, pytest only shows "no tests ran" instead.

@mberkowitz03 mberkowitz03 linked a pull request Apr 26, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: marks related to marks, either the general marks or builtin type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant