From a423c401801615d6fe21eb02feb55f4c09db1147 Mon Sep 17 00:00:00 2001 From: Maksim Stepanov <17935127+delatrie@users.noreply.github.com> Date: Mon, 4 Mar 2024 20:26:26 +0700 Subject: [PATCH] Revert getfixturedefs fix for pytest < 8.1 --- allure-pytest/src/listener.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/allure-pytest/src/listener.py b/allure-pytest/src/listener.py index dea558f2..eb222bc0 100644 --- a/allure-pytest/src/listener.py +++ b/allure-pytest/src/listener.py @@ -1,5 +1,7 @@ import pytest import doctest +from packaging import version + import allure_commons from allure_commons.utils import now from allure_commons.utils import uuid4 @@ -347,13 +349,23 @@ def _test_fixtures(item): if hasattr(item, "_request") and hasattr(item._request, "fixturenames"): for name in item._request.fixturenames: - fixturedefs_pytest = fixturemanager.getfixturedefs(name, item) + fixturedefs_pytest = _getfixturedefs(fixturemanager, name, item) if fixturedefs_pytest: fixturedefs.extend(fixturedefs_pytest) return fixturedefs +def _getfixturedefs(fixturemanager, name, item): + # See pytest-dev/pytest#11785 + itemarg = item if __is_pytest8_1_or_greater() else item.nodeid + return fixturemanager.getfixturedefs(name, itemarg) + + +def __is_pytest8_1_or_greater(): + return version.parse(pytest.__version__) >= version.parse("8.1") + + def _exception_brokes_test(exception): return not isinstance(exception, ( AssertionError,