Merge remote-tracking branch 'upstream/features' into features
This commit is contained in:
commit
d483b401ee
|
@ -871,6 +871,11 @@ class FixtureFunctionMarker(object):
|
||||||
if isclass(function):
|
if isclass(function):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"class fixtures not supported (may be in the future)")
|
"class fixtures not supported (may be in the future)")
|
||||||
|
|
||||||
|
if getattr(function, "_pytestfixturefunction", False):
|
||||||
|
raise ValueError(
|
||||||
|
"fixture is being applied more than once to the same function")
|
||||||
|
|
||||||
function._pytestfixturefunction = self
|
function._pytestfixturefunction = self
|
||||||
return function
|
return function
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Now when ``@pytest.fixture`` is applied more than once to the same function a ``ValueError`` is raised. This buggy behavior would cause surprising problems and if was working for a test suite it was mostly by accident.
|
|
@ -3055,6 +3055,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):
|
||||||
|
|
Loading…
Reference in New Issue