fix `filterwarnings` mark not registered

This commit is contained in:
Sankt Petersbug 2018-08-14 16:07:29 -05:00
parent b88e09a697
commit 6367f0f5f1
2 changed files with 23 additions and 0 deletions

View File

@ -49,6 +49,14 @@ def pytest_addoption(parser):
)
def pytest_configure(config):
config.addinivalue_line(
"markers",
"filterwarnings(warning): add a warning filter to the given test. "
"see http://pytest.org/latest/warnings.html#pytest-mark-filterwarnings ",
)
@contextmanager
def catch_warnings_for_item(item):
"""

View File

@ -287,3 +287,18 @@ def test_non_string_warning_argument(testdir):
)
result = testdir.runpytest("-W", "always")
result.stdout.fnmatch_lines(["*= 1 passed, 1 warnings in *"])
def test_filterwarnings_mark_registration(testdir):
"""Ensure filterwarnings mark is registered"""
testdir.makepyfile(
"""
import pytest
@pytest.mark.filterwarnings('error')
def test_error():
assert True
"""
)
result = testdir.runpytest("--strict")
assert result.ret == 0