Skip to content

Commit ef59880

Browse files
committed
Adapt to getfixturedefs change in pytest 8.1
The signature of this (private) function will change in the upcoming pytest 8.1 release: pytest-dev/pytest#11785
1 parent 2c934ec commit ef59880

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pytest_harvest/results_session.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,11 @@ def get_pytest_params(item):
504504
if is_lazy_value_or_tupleitem_with_int_base(param_value):
505505
# remove the int base so that pandas does not interprete it as an int.
506506
param_value = param_value.clone(remove_int_base=True)
507-
if item.session._fixturemanager.getfixturedefs(param_name, item.nodeid) is not None:
507+
if hasattr(pytest, "version_tuple") and pytest.version_tuple >= (8, 1):
508+
fixturedefs = item.session._fixturemanager.getfixturedefs(param_name, item)
509+
else:
510+
fixturedefs = item.session._fixturemanager.getfixturedefs(param_name, item.nodeid)
511+
if fixturedefs is not None:
508512
# Fixture parameters have the same name than the fixtures themselves! change it
509513
param_dct[param_name + '_param'] = param_value
510514
else:
@@ -530,7 +534,11 @@ def get_pytest_fixture_names(item):
530534
for param_name in item.fixturenames: # note: item.funcargnames gives the exact same list
531535
# if hasattr(item, 'callspec'): # NO! it would only return fixtures when they are parametrized
532536
# if param_name in item.callspec.params: NO ! it would only return fixtures when they are *directly* parametrized
533-
if item.session._fixturemanager.getfixturedefs(param_name, item.nodeid) is not None:
537+
if hasattr(pytest, "version_tuple") and pytest.version_tuple >= (8, 1):
538+
fixturedefs = item.session._fixturemanager.getfixturedefs(param_name, item)
539+
else:
540+
fixturedefs = item.session._fixturemanager.getfixturedefs(param_name, item.nodeid)
541+
if fixturedefs is not None:
534542
fixture_names.append(param_name)
535543

536544
return fixture_names

0 commit comments

Comments
 (0)