python: fix confused docstring of `Metafunc._resolve_arg_ids`

The docstring (and function name itself) described things as if IDs are
being assigned to the argnames, but actually they're assigned to the
parameter sets.
This commit is contained in:
Ran Benita 2022-01-21 16:16:40 +02:00
parent 6672a10354
commit 471634d6bd
1 changed files with 23 additions and 16 deletions

View File

@ -1118,7 +1118,7 @@ class Metafunc:
It will also override any fixture-function defined scope, allowing It will also override any fixture-function defined scope, allowing
to set a dynamic scope using test context or configuration. to set a dynamic scope using test context or configuration.
""" """
argnames, parameters = ParameterSet._for_parametrize( argnames, parametersets = ParameterSet._for_parametrize(
argnames, argnames,
argvalues, argvalues,
self.function, self.function,
@ -1150,8 +1150,8 @@ class Metafunc:
if generated_ids is not None: if generated_ids is not None:
ids = generated_ids ids = generated_ids
ids = self._resolve_arg_ids( ids = self._resolve_parameter_set_ids(
argnames, ids, parameters, nodeid=self.definition.nodeid argnames, ids, parametersets, nodeid=self.definition.nodeid
) )
# Store used (possibly generated) ids with parametrize Marks. # Store used (possibly generated) ids with parametrize Marks.
@ -1163,7 +1163,9 @@ class Metafunc:
# of all calls. # of all calls.
newcalls = [] newcalls = []
for callspec in self._calls or [CallSpec2()]: for callspec in self._calls or [CallSpec2()]:
for param_index, (param_id, param_set) in enumerate(zip(ids, parameters)): for param_index, (param_id, param_set) in enumerate(
zip(ids, parametersets)
):
newcallspec = callspec.setmulti( newcallspec = callspec.setmulti(
valtypes=arg_values_types, valtypes=arg_values_types,
argnames=argnames, argnames=argnames,
@ -1176,7 +1178,7 @@ class Metafunc:
newcalls.append(newcallspec) newcalls.append(newcallspec)
self._calls = newcalls self._calls = newcalls
def _resolve_arg_ids( def _resolve_parameter_set_ids(
self, self,
argnames: Sequence[str], argnames: Sequence[str],
ids: Optional[ ids: Optional[
@ -1185,18 +1187,23 @@ class Metafunc:
Callable[[Any], Optional[object]], Callable[[Any], Optional[object]],
] ]
], ],
parameters: Sequence[ParameterSet], parametersets: Sequence[ParameterSet],
nodeid: str, nodeid: str,
) -> List[str]: ) -> List[str]:
"""Resolve the actual ids for the given argnames, based on the ``ids`` parameter given """Resolve the actual ids for the given parameter sets.
to ``parametrize``.
:param List[str] argnames: List of argument names passed to ``parametrize()``. :param argnames:
:param ids: The ids parameter of the parametrized call (see docs). Argument names passed to ``parametrize()``.
:param List[ParameterSet] parameters: The list of parameter values, same size as ``argnames``. :param ids:
:param str str: The nodeid of the item that generated this parametrized call. The `ids` parameter of the ``parametrize()`` call (see docs).
:rtype: List[str] :param parametersets:
:returns: The list of ids for each argname given. The parameter sets, each containing a set of values corresponding
to ``argnames``.
:param nodeid str:
The nodeid of the definition item that generated this
parametrization.
:returns:
List with ids for each parameter set given.
""" """
if ids is None: if ids is None:
idfn = None idfn = None
@ -1206,8 +1213,8 @@ class Metafunc:
ids_ = None ids_ = None
else: else:
idfn = None idfn = None
ids_ = self._validate_ids(ids, parameters, self.function.__name__) ids_ = self._validate_ids(ids, parametersets, self.function.__name__)
return idmaker(argnames, parameters, idfn, ids_, self.config, nodeid=nodeid) return idmaker(argnames, parametersets, idfn, ids_, self.config, nodeid=nodeid)
def _validate_ids( def _validate_ids(
self, self,