Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide error fixture applied to the same func #2849

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions _pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,10 @@ def __call__(self, function):
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

Expand Down
1 change: 1 addition & 0 deletions changelog/2334.feature
Original file line number Diff line number Diff line change
@@ -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.