summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorBruno Oliveira <nicoddemus@gmail.com>2018-04-23 22:17:46 -0300
committerBruno Oliveira <nicoddemus@gmail.com>2018-04-23 22:17:46 -0300
commit03850cf962e9c3c9b8d05a63a2fde0ba8ec0f7fa (patch)
tree57fb448a050888d22015aacd826cf387e982f0d1 /testing
parenta7a39f136450e4608a61e0d77336ffd21328a915 (diff)
downloadpytest-03850cf962e9c3c9b8d05a63a2fde0ba8ec0f7fa.tar.gz
Add test for applying fixture twice
Fix #2334
Diffstat (limited to 'testing')
-rw-r--r--testing/python/fixture.py8
1 files changed, 8 insertions, 0 deletions
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):