Skip to content

Commit

Permalink
Fix compatibility with pytest 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
elchupanebrej committed Jan 30, 2024
1 parent e144e8a commit 23fe74d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/pytest_bdd/compatibility/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ def is_pytest_version_greater(version: str):
return compare_distribution_version("pytest", version, ge)


PYTEST6, PYTEST61, PYTEST62, PYTEST7 = map(
PYTEST6, PYTEST61, PYTEST62, PYTEST7, PYTEST8 = map(
is_pytest_version_greater,
[
"6.0",
"6.1",
"6.2",
"7.0",
"8.0",
],
)

Expand Down Expand Up @@ -191,3 +192,7 @@ def is_set(obj):

def is_set(obj):
return type(obj) is not object


def get_metafunc_call_arg(call, arg):
return call.params[arg] if PYTEST8 else call.funcargs[arg]
16 changes: 12 additions & 4 deletions src/pytest_bdd/message_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@
TestStepStarted,
Timestamp,
)
from pytest_bdd.compatibility.pytest import Config, FixtureDef, FixtureRequest, Parser, get_config_root_path, is_set
from pytest_bdd.compatibility.pytest import (
Config,
FixtureDef,
FixtureRequest,
Parser,
get_config_root_path,
get_metafunc_call_arg,
is_set,
)
from pytest_bdd.packaging import get_distribution_version
from pytest_bdd.steps import StepHandler
from pytest_bdd.utils import PytestBDDIdGeneratorHandler, deepattrgetter
Expand Down Expand Up @@ -142,9 +150,9 @@ def pytest_generate_tests(self, metafunc):
feature_registry = set()
pickle_registry = set()
for call in metafunc._calls:
feature = call.funcargs["feature"]
pickle = call.funcargs["scenario"]
feature_source: Source = call.funcargs["feature_source"]
feature = get_metafunc_call_arg(call, "feature")
pickle = get_metafunc_call_arg(call, "scenario")
feature_source: Source = get_metafunc_call_arg(call, "feature_source")

if is_set(feature) and feature_source.uri not in feature_registry:
feature_registry.add(feature_source.uri)
Expand Down
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tox]
envlist =
py312-pre-commit-lin
py312-pytest{625, 74, 73, 72, 71, 70, latest}-mypy-lin
py312-pytest{625, 74, 73, 72, 71, 70, latest}-coverage-lin
py312-pytest{625, 80, 74, 73, 72, 71, 70, latest}-mypy-lin
py312-pytest{625, 80, 74, 73, 72, 71, 70, latest}-coverage-lin
py312-pytestlatest-gherkin{24, latest}-xdist-coverage-{lin, win, mac}
py312-pytestlatets-allure-coverage-{lin, win, mac}
py39-pytest{62, 61, 60, 54, 53, 52, 51, 50}-coverage-lin
Expand Down Expand Up @@ -36,7 +36,8 @@ deps =
pytest72: pytest~=7.2.0
pytest73: pytest~=7.3.0
pytest74: pytest~=7.4.0
pytestlatest: pytest<8.0
pytest80: pytest~=8.0.0
pytestlatest: pytest
xdist: pytest-xdist
setenv =
COLUMNS = 80
Expand Down

0 comments on commit 23fe74d

Please sign in to comment.