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 compatibility with pytest 8.1 #795

Merged
merged 7 commits into from
Mar 11, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion allure-pytest/src/listener.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.nodeid)
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,
Expand Down
Loading