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

Fix getfixturedefs call #12

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

Conversation

MaksimKravchuk
Copy link

@MaksimKravchuk MaksimKravchuk commented Dec 11, 2024

Problem:
Test runs with --show-fixture-duplicates fail with error:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/user/Code/e2e/venv/lib/python3.12/site-packages/_pytest/fixtures.py", line 1771, in _matchfactories
INTERNALERROR>     parentnodeids = {n.nodeid for n in node.iter_parents()}
INTERNALERROR>                                        ^^^^^^^^^^^^^^^^^
INTERNALERROR> AttributeError: 'str' object has no attribute 'iter_parents'
INTERNALERROR> 
INTERNALERROR> During handling of the above exception, another exception occurred:
INTERNALERROR> 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/user/Code/e2e/venv/lib/python3.12/site-packages/_pytest/main.py", line 285, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>                          ^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/user/Code/e2e/venv/lib/python3.12/site-packages/pytest_fixture_tools/plugin.py", line 94, in _show_fixture_duplicates_main
INTERNALERROR>     fixturedefs = fm.getfixturedefs(argname, item.nodeid)
INTERNALERROR>                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/user/Code/e2e/venv/lib/python3.12/site-packages/_pytest/fixtures.py", line 1765, in getfixturedefs
INTERNALERROR>     return tuple(self._matchfactories(fixturedefs, node))
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "/Users/user/Code/e2e/venv/lib/python3.12/site-packages/_pytest/fixtures.py", line 1773, in _matchfactories
INTERNALERROR>     raise ValueError("node must be a Node instance")
INTERNALERROR> ValueError: node must be a Node instance

It happens because getfixturedefs takes a Node object, not a node ID string.
https://github.com/pytest-dev/pytest/blob/949c7711b3e22ab94110f1ae4fc307cda2f9e379/src/_pytest/fixtures.py#L1824

This PR fix the problem.


This change is Reviewable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant