Warn when a mark is applied to a fixture

Fixes #3664
This commit is contained in:
Thomas Grainger
2021-03-10 13:47:14 +00:00
parent 35df3e68d5
commit 3f71680ac0
6 changed files with 30 additions and 2 deletions

View File

@@ -3612,6 +3612,24 @@ class TestShowFixtures:
def foo():
raise NotImplementedError()
def test_fixture_disallow_on_marked_functions(self):
"""Test that applying @pytest.fixture to a marked function warns (#3364)."""
with pytest.warns(pytest.PytestDeprecationWarning):
@pytest.fixture
@pytest.mark.usefixtures("tmp_path")
def foo():
raise NotImplementedError()
def test_fixture_disallow_marks_on_fixtures(self):
"""Test that applying a mark to a fixture warns (#3364)."""
with pytest.warns(pytest.PytestDeprecationWarning):
@pytest.mark.usefixtures("tmp_path")
@pytest.fixture
def foo():
raise NotImplementedError()
class TestContextManagerFixtureFuncs:
def test_simple(self, pytester: Pytester) -> None: