diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index 64d21b9f6..b9d1070ce 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -827,6 +827,10 @@ class FixtureFunctionMarker: if isclass(function): raise ValueError( "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 return function diff --git a/changelog/2334.feature b/changelog/2334.feature new file mode 100644 index 000000000..5aec67994 --- /dev/null +++ b/changelog/2334.feature @@ -0,0 +1 @@ +Now when @pytest.fixture is being applied to the same function ValueError is raised. \ No newline at end of file