pytest-dev / pytest-dev/pytest

Emit a warning when using an unregistered mark via `-m`

Open
#10,514 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: marks type: proposal
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

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?).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing pytest's -m marker-expression handling and compare it with existing warnings for applying unregistered marks. Done means unknown marks used in a -m expression are surfaced consistently, with the warning-versus-error behavior and affected tests made explicit.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.