Skip to content

filterwarnings Is an Unregistered Marker #3671

@0cjs

Description

@0cjs

The following test:

import warnings, pytest

@pytest.mark.filterwarnings('ignore:whatever')                                 
def test_filter():
       warn('whatever')

when run with pytest -W error test.py, passes, as expected.

However, adding the --strict command line option results in:

test.py:3: in <module>
    @pytest.mark.filterwarnings('ignore:whatever')
co/py-virtualenv/36dev/lib/python3.6/site-packages/_pytest/mark/structures.py:355: in __getattr__
    self._check(name)
co/py-virtualenv/36dev/lib/python3.6/site-packages/_pytest/mark/structures.py:371: in _check
    raise AttributeError("%r not a registered marker" % (name,))
E   AttributeError: 'filterwarnings' not a registered marker

filterwarnings also does not appear in the output of pytest --markers.

While waiting for this to be fixed, the workaround is to register filterwarnings with your per-project list of valid markers, e.g.:

pytest -o 'markers=filterwarnings' --strict -W error z.py

The above has been confirmed on:

  • platform linux -- Python 3.6.5, pytest-3.6.3, py-1.5.3, pluggy-0.6.0
  • platform linux -- Python 3.4.3, pytest-3.5.1, py-1.5.3, pluggy-0.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions