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

Raises an error when a fixture conflict for the same file #13058

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dongfangtianyu
Copy link
Contributor

close #12952.

Detect fixtures with the same name and from the same nodeid.

  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits.
  • Add text like closes #XYZW
  • Create a new changelog file in the changelog folder

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Dec 13, 2024
@bluetech
Copy link
Member

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)
Copy link
Member

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

Copy link
Contributor Author

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 == ""
Copy link
Contributor Author

@dongfangtianyu dongfangtianyu Dec 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided (automation) changelog entry is part of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Override a fixture on a test module level:with "name" key_word_arg, its may not Override
4 participants