Merge pull request #3815 from sankt-petersbug/fix-3671
Fix #3671 - `filterwarnings` Is an Unregistered Marker
This commit is contained in:
commit
ca1bb9a3a1
1
AUTHORS
1
AUTHORS
|
@ -182,6 +182,7 @@ Russel Winder
|
||||||
Ryan Wooden
|
Ryan Wooden
|
||||||
Samuel Dion-Girardeau
|
Samuel Dion-Girardeau
|
||||||
Samuele Pedroni
|
Samuele Pedroni
|
||||||
|
Sankt Petersbug
|
||||||
Segev Finer
|
Segev Finer
|
||||||
Serhii Mozghovyi
|
Serhii Mozghovyi
|
||||||
Simon Gomizelj
|
Simon Gomizelj
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix ``filterwarnings`` mark not registered
|
|
@ -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
|
@contextmanager
|
||||||
def catch_warnings_for_item(item):
|
def catch_warnings_for_item(item):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -287,3 +287,18 @@ def test_non_string_warning_argument(testdir):
|
||||||
)
|
)
|
||||||
result = testdir.runpytest("-W", "always")
|
result = testdir.runpytest("-W", "always")
|
||||||
result.stdout.fnmatch_lines(["*= 1 passed, 1 warnings in *"])
|
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_func():
|
||||||
|
pass
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = testdir.runpytest("--strict")
|
||||||
|
assert result.ret == 0
|
||||||
|
|
Loading…
Reference in New Issue