Skip to content

Commit

Permalink
Fix parametrized lazy fixture with pytest 7
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-petrov committed Jul 22, 2024
1 parent 52870ae commit 2257370
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
20 changes: 10 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ include = [{ path = "tests", format = ["sdist"] }]

[tool.poetry.dependencies]
python = "^3.8"
pytest = ">=7"
pytest = "^7"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.5.0"
Expand Down
7 changes: 4 additions & 3 deletions pytest_lazy_fixtures/normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ def _normalize_call(callspec, metafunc, used_keys):
fm = metafunc.config.pluginmanager.get_plugin("funcmanage")

used_keys = used_keys or set()
valtype_keys = callspec.params.keys() - used_keys
params = callspec.params.copy() if pytest.version_tuple >= (8, 0, 0) else {**callspec.params, **callspec.funcargs}
valtype_keys = params.keys() - used_keys

for arg in valtype_keys:
value = callspec.params[arg]
value = params[arg]
fixturenames_closure, arg2fixturedefs = _get_fixturenames_closure_and_arg2fixturedefs(fm, metafunc, value)

if fixturenames_closure and arg2fixturedefs:
extra_fixturenames = [fname for fname in fixturenames_closure if fname not in callspec.params]
extra_fixturenames = [fname for fname in fixturenames_closure if fname not in params]

newmetafunc = _copy_metafunc(metafunc)
newmetafunc.fixturenames = extra_fixturenames
Expand Down

0 comments on commit 2257370

Please sign in to comment.