From cfd16d0dac1c935952b892bfbc225978c9b25de3 Mon Sep 17 00:00:00 2001 From: ApaDoctor Date: Thu, 5 Oct 2017 11:45:35 +0300 Subject: [PATCH] provide error fixture applied to the same func provide error fixture applied to the same func provide error fixture applied to the same func --- _pytest/fixtures.py | 4 ++++ changelog/2334.feature | 1 + 2 files changed, 5 insertions(+) create mode 100644 changelog/2334.feature 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