Add test for applying fixture twice

Fix #2334
This commit is contained in:
Bruno Oliveira 2018-04-23 22:17:46 -03:00
parent a7a39f1364
commit 03850cf962
1 changed files with 8 additions and 0 deletions

View File

@ -2812,6 +2812,14 @@ class TestShowFixtures(object):
Hi from test module Hi from test module
''') ''')
def test_fixture_disallow_twice(self):
"""Test that applying @pytest.fixture twice generates an error (#2334)."""
with pytest.raises(ValueError):
@pytest.fixture
@pytest.fixture
def foo():
pass
@pytest.mark.parametrize('flavor', ['fixture', 'yield_fixture']) @pytest.mark.parametrize('flavor', ['fixture', 'yield_fixture'])
class TestContextManagerFixtureFuncs(object): class TestContextManagerFixtureFuncs(object):