From 03850cf962e9c3c9b8d05a63a2fde0ba8ec0f7fa Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 23 Apr 2018 22:17:46 -0300 Subject: [PATCH] Add test for applying fixture twice Fix #2334 --- testing/python/fixture.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/testing/python/fixture.py b/testing/python/fixture.py index 1e58a5550..26cde4c93 100644 --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -2812,6 +2812,14 @@ class TestShowFixtures(object): 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']) class TestContextManagerFixtureFuncs(object):