Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / pytest-lazy-fixture / pytest-8-compatible.patch
blob26fcd77166676f0fbeb2a54a0885864c4c08a24d
1 diff --git a/pytest_lazyfixture.py b/pytest_lazyfixture.py
2 index abf5db5..df83ce7 100644
3 --- a/pytest_lazyfixture.py
4 +++ b/pytest_lazyfixture.py
5 @@ -71,14 +71,13 @@ def pytest_make_parametrize_id(config, val, argname):
6 def pytest_generate_tests(metafunc):
7 yield
9 - normalize_metafunc_calls(metafunc, 'funcargs')
10 - normalize_metafunc_calls(metafunc, 'params')
11 + normalize_metafunc_calls(metafunc)
14 -def normalize_metafunc_calls(metafunc, valtype, used_keys=None):
15 +def normalize_metafunc_calls(metafunc, used_keys=None):
16 newcalls = []
17 for callspec in metafunc._calls:
18 - calls = normalize_call(callspec, metafunc, valtype, used_keys)
19 + calls = normalize_call(callspec, metafunc, used_keys)
20 newcalls.extend(calls)
21 metafunc._calls = newcalls
23 @@ -98,17 +97,21 @@ def copy_metafunc(metafunc):
24 return copied
27 -def normalize_call(callspec, metafunc, valtype, used_keys):
28 +def normalize_call(callspec, metafunc, used_keys):
29 fm = metafunc.config.pluginmanager.get_plugin('funcmanage')
31 used_keys = used_keys or set()
32 - valtype_keys = set(getattr(callspec, valtype).keys()) - used_keys
33 + keys = set(callspec.params.keys()) - used_keys
34 + print(used_keys, keys)
36 - for arg in valtype_keys:
37 - val = getattr(callspec, valtype)[arg]
38 + for arg in keys:
39 + val = callspec.params[arg]
40 if is_lazy_fixture(val):
41 try:
42 - _, fixturenames_closure, arg2fixturedefs = fm.getfixtureclosure([val.name], metafunc.definition.parent)
43 + if pytest.version_tuple >= (8, 0, 0):
44 + fixturenames_closure, arg2fixturedefs = fm.getfixtureclosure(metafunc.definition.parent, [val.name], {})
45 + else:
46 + _, fixturenames_closure, arg2fixturedefs = fm.getfixtureclosure([val.name], metafunc.definition.parent)
47 except ValueError:
48 # 3.6.0 <= pytest < 3.7.0; `FixtureManager.getfixtureclosure` returns 2 values
49 fixturenames_closure, arg2fixturedefs = fm.getfixtureclosure([val.name], metafunc.definition.parent)
50 @@ -117,14 +120,14 @@ def normalize_call(callspec, metafunc, valtype, used_keys):
51 fixturenames_closure, arg2fixturedefs = fm.getfixtureclosure([val.name], current_node)
53 extra_fixturenames = [fname for fname in fixturenames_closure
54 - if fname not in callspec.params and fname not in callspec.funcargs]
55 + if fname not in callspec.params]# and fname not in callspec.funcargs]
57 newmetafunc = copy_metafunc(metafunc)
58 newmetafunc.fixturenames = extra_fixturenames
59 newmetafunc._arg2fixturedefs.update(arg2fixturedefs)
60 newmetafunc._calls = [callspec]
61 fm.pytest_generate_tests(newmetafunc)
62 - normalize_metafunc_calls(newmetafunc, valtype, used_keys | set([arg]))
63 + normalize_metafunc_calls(newmetafunc, used_keys | set([arg]))
64 return newmetafunc._calls
66 used_keys.add(arg)