Skip to content

Commit 03850cf

Browse files
committed
Add test for applying fixture twice
Fix #2334
1 parent a7a39f1 commit 03850cf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

testing/python/fixture.py

+8
Original file line numberDiff line numberDiff line change
@@ -2812,6 +2812,14 @@ def test_bar(arg1):
28122812
Hi from test module
28132813
''')
28142814

2815+
def test_fixture_disallow_twice(self):
2816+
"""Test that applying @pytest.fixture twice generates an error (#2334)."""
2817+
with pytest.raises(ValueError):
2818+
@pytest.fixture
2819+
@pytest.fixture
2820+
def foo():
2821+
pass
2822+
28152823

28162824
@pytest.mark.parametrize('flavor', ['fixture', 'yield_fixture'])
28172825
class TestContextManagerFixtureFuncs(object):

0 commit comments

Comments
 (0)