test-framework: Update test-framework to work with pytest >= 7.X and python >= 3.7
Signed-off-by: Kamil Gierszewski <kamil.gierszewski@huawei.com>
This commit is contained in:
parent
83e8064bfb
commit
5e9bba66c2
@ -1,5 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Copyright(c) 2020-2021 Intel Corporation
|
# Copyright(c) 2020-2021 Intel Corporation
|
||||||
|
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -31,6 +32,7 @@ import random
|
|||||||
|
|
||||||
from core.test_run import TestRun
|
from core.test_run import TestRun
|
||||||
|
|
||||||
|
|
||||||
def testcase_id(param_set):
|
def testcase_id(param_set):
|
||||||
if len(param_set.values) == 1:
|
if len(param_set.values) == 1:
|
||||||
return param_set.values[0]
|
return param_set.values[0]
|
||||||
@ -77,7 +79,6 @@ def register_testcases(metafunc, argnames, argvals):
|
|||||||
"""
|
"""
|
||||||
from _pytest.python import CallSpec2, _find_parametrized_scope
|
from _pytest.python import CallSpec2, _find_parametrized_scope
|
||||||
from _pytest.mark import ParameterSet
|
from _pytest.mark import ParameterSet
|
||||||
from _pytest.fixtures import scope2index
|
|
||||||
|
|
||||||
parameter_sets = [ParameterSet(values=val, marks=[], id=None) for val in argvals]
|
parameter_sets = [ParameterSet(values=val, marks=[], id=None) for val in argvals]
|
||||||
metafunc._validate_if_using_arg_names(argnames, False)
|
metafunc._validate_if_using_arg_names(argnames, False)
|
||||||
@ -86,21 +87,20 @@ def register_testcases(metafunc, argnames, argvals):
|
|||||||
|
|
||||||
ids = [testcase_id(param_set) for param_set in parameter_sets]
|
ids = [testcase_id(param_set) for param_set in parameter_sets]
|
||||||
|
|
||||||
scope = _find_parametrized_scope(argnames, metafunc._arg2fixturedefs, False)
|
scope_ = _find_parametrized_scope(argnames=argnames, arg2fixturedefs=metafunc._arg2fixturedefs,
|
||||||
scopenum = scope2index(scope, descr=f"parametrizex() call in {metafunc.function.__name__}")
|
indirect=False)
|
||||||
|
|
||||||
calls = []
|
calls = []
|
||||||
for callspec in metafunc._calls or [CallSpec2(metafunc)]:
|
for callspec in metafunc._calls or [CallSpec2()]:
|
||||||
for param_index, (param_id, param_set) in enumerate(zip(ids, parameter_sets)):
|
for param_index, (param_id, param_set) in enumerate(zip(ids, parameter_sets)):
|
||||||
newcallspec = callspec.copy()
|
newcallspec = callspec.setmulti(
|
||||||
newcallspec.setmulti2(
|
valtypes=arg_value_types,
|
||||||
arg_value_types,
|
argnames=argnames,
|
||||||
argnames,
|
valset=param_set.values,
|
||||||
param_set.values,
|
id=str(param_id),
|
||||||
param_id,
|
marks=param_set.marks,
|
||||||
param_set.marks,
|
scope=scope_,
|
||||||
scopenum,
|
param_index=param_index,
|
||||||
param_index,
|
|
||||||
)
|
)
|
||||||
calls.append(newcallspec)
|
calls.append(newcallspec)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user