-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Raises an error when a fixture conflict for the same file #13058
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR @dongfangtianyu. I left a comment on the issue #12952 (comment) that we should discuss to decide if this is the right fix. |
f"Fixture definition conflict: {name!r} has multiple implementations," | ||
f"namely {faclist[-1].func!r} and {func} (from: {nodeid!r})." | ||
) | ||
print(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's turn this into a warning for now
We also might want to propose a ruff rule for this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @RonnyPfannschmidt , Could you please let me know which type is more appropriate: PytestWarning
or PytestDeprecationWarning
?
@@ -1728,6 +1728,20 @@ def _register_fixture( | |||
) | |||
|
|||
faclist = self._arg2fixturedefs.setdefault(name, []) | |||
|
|||
by_plugin = fixture_def.baseid == "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit tricky : If the fixture comes from the conftest.py
file in the root path, it will bypass this check. Even if it is not bypassed, can't catch errors or warnings.
close #12952.
Detect fixtures with the same name and from the same nodeid.
closes #XYZW
changelog
folder