Show deprecation warnings by default if no other filters are configured
Fix #2908
This commit is contained in:
@@ -8,10 +8,6 @@ import pytest
|
||||
from _pytest.main import EXIT_NOTESTSCOLLECTED
|
||||
from _pytest.nodes import Collector
|
||||
|
||||
ignore_parametrized_marks = pytest.mark.filterwarnings(
|
||||
"ignore:Applying marks directly to parameters"
|
||||
)
|
||||
|
||||
|
||||
class TestModule(object):
|
||||
def test_failing_import(self, testdir):
|
||||
@@ -456,6 +452,13 @@ class TestGenerator(object):
|
||||
|
||||
|
||||
class TestFunction(object):
|
||||
@pytest.fixture
|
||||
def ignore_parametrized_marks_args(self):
|
||||
"""Provides arguments to pytester.runpytest() to ignore the warning about marks being applied directly
|
||||
to parameters.
|
||||
"""
|
||||
return ("-W", "ignore:Applying marks directly to parameters")
|
||||
|
||||
def test_getmodulecollector(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
modcol = item.getparent(pytest.Module)
|
||||
@@ -669,7 +672,7 @@ class TestFunction(object):
|
||||
rec = testdir.inline_run()
|
||||
rec.assertoutcome(passed=1)
|
||||
|
||||
@ignore_parametrized_marks
|
||||
@pytest.mark.filterwarnings("ignore:Applying marks directly to parameters")
|
||||
def test_parametrize_with_mark(self, testdir):
|
||||
items = testdir.getitems(
|
||||
"""
|
||||
@@ -755,8 +758,7 @@ class TestFunction(object):
|
||||
assert colitems[2].name == "test2[a-c]"
|
||||
assert colitems[3].name == "test2[b-c]"
|
||||
|
||||
@ignore_parametrized_marks
|
||||
def test_parametrize_skipif(self, testdir):
|
||||
def test_parametrize_skipif(self, testdir, ignore_parametrized_marks_args):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
@@ -768,11 +770,10 @@ class TestFunction(object):
|
||||
assert x < 2
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
result = testdir.runpytest(*ignore_parametrized_marks_args)
|
||||
result.stdout.fnmatch_lines("* 2 passed, 1 skipped in *")
|
||||
|
||||
@ignore_parametrized_marks
|
||||
def test_parametrize_skip(self, testdir):
|
||||
def test_parametrize_skip(self, testdir, ignore_parametrized_marks_args):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
@@ -784,11 +785,10 @@ class TestFunction(object):
|
||||
assert x < 2
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
result = testdir.runpytest(*ignore_parametrized_marks_args)
|
||||
result.stdout.fnmatch_lines("* 2 passed, 1 skipped in *")
|
||||
|
||||
@ignore_parametrized_marks
|
||||
def test_parametrize_skipif_no_skip(self, testdir):
|
||||
def test_parametrize_skipif_no_skip(self, testdir, ignore_parametrized_marks_args):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
@@ -800,11 +800,10 @@ class TestFunction(object):
|
||||
assert x < 2
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
result = testdir.runpytest(*ignore_parametrized_marks_args)
|
||||
result.stdout.fnmatch_lines("* 1 failed, 2 passed in *")
|
||||
|
||||
@ignore_parametrized_marks
|
||||
def test_parametrize_xfail(self, testdir):
|
||||
def test_parametrize_xfail(self, testdir, ignore_parametrized_marks_args):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
@@ -816,11 +815,10 @@ class TestFunction(object):
|
||||
assert x < 2
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
result = testdir.runpytest(*ignore_parametrized_marks_args)
|
||||
result.stdout.fnmatch_lines("* 2 passed, 1 xfailed in *")
|
||||
|
||||
@ignore_parametrized_marks
|
||||
def test_parametrize_passed(self, testdir):
|
||||
def test_parametrize_passed(self, testdir, ignore_parametrized_marks_args):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
@@ -832,11 +830,10 @@ class TestFunction(object):
|
||||
pass
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
result = testdir.runpytest(*ignore_parametrized_marks_args)
|
||||
result.stdout.fnmatch_lines("* 2 passed, 1 xpassed in *")
|
||||
|
||||
@ignore_parametrized_marks
|
||||
def test_parametrize_xfail_passed(self, testdir):
|
||||
def test_parametrize_xfail_passed(self, testdir, ignore_parametrized_marks_args):
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
@@ -848,7 +845,7 @@ class TestFunction(object):
|
||||
pass
|
||||
"""
|
||||
)
|
||||
result = testdir.runpytest()
|
||||
result = testdir.runpytest(*ignore_parametrized_marks_args)
|
||||
result.stdout.fnmatch_lines("* 3 passed in *")
|
||||
|
||||
def test_function_original_name(self, testdir):
|
||||
|
||||
Reference in New Issue
Block a user