Skip to content

PytestUnknownMarkWarning should reference user code, not pytest #5928

Closed
@allanlewis

Description

@allanlewis

When an unknown mark is used, Pytest reports a PytestUnknownMarkWarning. However, this is reported at the level of the warning call, which is obviously in pytest's code, which is unhelpful to users. This warning should be reported at the level of the user's code.

Example:

@pytest.mark.foo
def test_bar():
    pass
$ pytest
...
========================================== warnings summary ===========================================
/home/stb-tester/.local/lib/python2.7/site-packages/_pytest/mark/structures.py:337
  /home/stb-tester/.local/lib/python2.7/site-packages/_pytest/mark/structures.py:337: PytestUnknownMarkWarning: Unknown pytest.mark.slow - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
    PytestUnknownMarkWarning,

-- Docs: https://docs.pytest.org/en/latest/warnings.html
...
  • a detailed description of the bug or suggestion
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

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