python: use clearer terminology for `_resolve_arg_value_types`
This commit is contained in:
parent
09b78737a5
commit
3ad3fc6b8f
|
@ -1363,9 +1363,9 @@ class Metafunc:
|
||||||
name2pseudofixturedef = node.stash.setdefault(
|
name2pseudofixturedef = node.stash.setdefault(
|
||||||
name2pseudofixturedef_key, default
|
name2pseudofixturedef_key, default
|
||||||
)
|
)
|
||||||
arg_values_types = self._resolve_arg_value_types(argnames, indirect)
|
arg_directness = self._resolve_args_directness(argnames, indirect)
|
||||||
for argname in argnames:
|
for argname in argnames:
|
||||||
if arg_values_types[argname] == "params":
|
if arg_directness[argname] == "indirect":
|
||||||
continue
|
continue
|
||||||
if name2pseudofixturedef is not None and argname in name2pseudofixturedef:
|
if name2pseudofixturedef is not None and argname in name2pseudofixturedef:
|
||||||
fixturedef = name2pseudofixturedef[argname]
|
fixturedef = name2pseudofixturedef[argname]
|
||||||
|
@ -1470,28 +1470,30 @@ class Metafunc:
|
||||||
|
|
||||||
return list(itertools.islice(ids, num_ids))
|
return list(itertools.islice(ids, num_ids))
|
||||||
|
|
||||||
def _resolve_arg_value_types(
|
def _resolve_args_directness(
|
||||||
self,
|
self,
|
||||||
argnames: Sequence[str],
|
argnames: Sequence[str],
|
||||||
indirect: Union[bool, Sequence[str]],
|
indirect: Union[bool, Sequence[str]],
|
||||||
) -> Dict[str, "Literal['params', 'funcargs']"]:
|
) -> Dict[str, Literal["indirect", "direct"]]:
|
||||||
"""Resolve if each parametrized argument must be considered a
|
"""Resolve if each parametrized argument must be considered an indirect
|
||||||
parameter to a fixture or a "funcarg" to the function, based on the
|
parameter to a fixture of the same name, or a direct parameter to the
|
||||||
``indirect`` parameter of the parametrized() call.
|
parametrized function, based on the ``indirect`` parameter of the
|
||||||
|
parametrized() call.
|
||||||
|
|
||||||
:param List[str] argnames: List of argument names passed to ``parametrize()``.
|
:param argnames:
|
||||||
:param indirect: Same as the ``indirect`` parameter of ``parametrize()``.
|
List of argument names passed to ``parametrize()``.
|
||||||
:rtype: Dict[str, str]
|
:param indirect:
|
||||||
A dict mapping each arg name to either:
|
Same as the ``indirect`` parameter of ``parametrize()``.
|
||||||
* "params" if the argname should be the parameter of a fixture of the same name.
|
:returns
|
||||||
* "funcargs" if the argname should be a parameter to the parametrized test function.
|
A dict mapping each arg name to either "indirect" or "direct".
|
||||||
"""
|
"""
|
||||||
|
arg_directness: Dict[str, Literal["indirect", "direct"]]
|
||||||
if isinstance(indirect, bool):
|
if isinstance(indirect, bool):
|
||||||
valtypes: Dict[str, Literal["params", "funcargs"]] = dict.fromkeys(
|
arg_directness = dict.fromkeys(
|
||||||
argnames, "params" if indirect else "funcargs"
|
argnames, "indirect" if indirect else "direct"
|
||||||
)
|
)
|
||||||
elif isinstance(indirect, Sequence):
|
elif isinstance(indirect, Sequence):
|
||||||
valtypes = dict.fromkeys(argnames, "funcargs")
|
arg_directness = dict.fromkeys(argnames, "direct")
|
||||||
for arg in indirect:
|
for arg in indirect:
|
||||||
if arg not in argnames:
|
if arg not in argnames:
|
||||||
fail(
|
fail(
|
||||||
|
@ -1500,7 +1502,7 @@ class Metafunc:
|
||||||
),
|
),
|
||||||
pytrace=False,
|
pytrace=False,
|
||||||
)
|
)
|
||||||
valtypes[arg] = "params"
|
arg_directness[arg] = "indirect"
|
||||||
else:
|
else:
|
||||||
fail(
|
fail(
|
||||||
"In {func}: expected Sequence or boolean for indirect, got {type}".format(
|
"In {func}: expected Sequence or boolean for indirect, got {type}".format(
|
||||||
|
@ -1508,7 +1510,7 @@ class Metafunc:
|
||||||
),
|
),
|
||||||
pytrace=False,
|
pytrace=False,
|
||||||
)
|
)
|
||||||
return valtypes
|
return arg_directness
|
||||||
|
|
||||||
def _validate_if_using_arg_names(
|
def _validate_if_using_arg_names(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Reference in New Issue