Skip to content

Commit 3e57cf6

Browse files
committed
mh_fixture: make it work with pytest-8.4.0
pytest-8.4.0 removed the __pytest_wrapped__ atribute on a fixture object, instead of unwrapping the object, it now keeps __wrapped__ that we can use instead. This commit makes sure we can work with both old and new pytest. See: pytest-dev/pytest#12473
1 parent 92163c9 commit 3e57cf6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pytest_mh/_private/plugin.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,9 +987,18 @@ def wrapper_yield(mh: MultihostFixture, *args, **kwargs):
987987
partial_parameters.extend(
988988
[param for key, param in full_sig.parameters.items() if key != "mh" and key not in mh_args]
989989
)
990-
fixture.__pytest_wrapped__.obj.func.__signature__ = inspect.Signature(
991-
partial_parameters, return_annotation=full_sig.return_annotation
992-
)
990+
991+
if hasattr(fixture, "__pytest_wrapped__"):
992+
obj = fixture.__pytest_wrapped__.obj
993+
elif hasattr(fixture, "__wrapped__"):
994+
obj = fixture.__wrapped__
995+
else:
996+
raise AttributeError(
997+
"Fixture object has no __pytest_wrapped__ nor __wrapped__ attribute, "
998+
"report this to pytest-mh upstream."
999+
)
1000+
1001+
obj.func.__signature__ = inspect.Signature(partial_parameters, return_annotation=full_sig.return_annotation)
9931002

9941003
return fixture
9951004

0 commit comments

Comments
 (0)