Skip to content

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?


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.

@dongfangtianyu dongfangtianyu changed the title Raises an error when a fixture conflict for the same file Triggers a warning when overriding fixtures at the same level Dec 20, 2024
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