Skip to content

Emit warnings on use of unknown marks #4826

@Zac-HD

Description

@Zac-HD

One of the most common problems I see, and help debug, is typos in @pytest.mark.whatever decorators. Just recently we've had #4639 and #4814, and I've read three sets of unrelated docs in the last week that explicitly point out the spelling of mark.parametrize (not parameterize!).

The --strict argument helps, but is clearly insufficient by default. On the other hand, it can't be an error until a major version bump.

Happily, there is a standard middle ground: warnings! I therefore propose to emit a warning every time an unknown name is used as an attribute of pytest.mark. The message should include how to register the mark, why unregistered marks are problematic, and note that this warning may become an error in a future version of pytest.

Unless there are major objections to this plan, I'll try for an implementation over the weekend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: marksrelated to marks, either the general marks or builtintype: enhancementnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions