Skip to content

Commit 471634d

Browse files
committed
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.
1 parent 6672a10 commit 471634d

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

src/_pytest/python.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ def parametrize(
11181118
It will also override any fixture-function defined scope, allowing
11191119
to set a dynamic scope using test context or configuration.
11201120
"""
1121-
argnames, parameters = ParameterSet._for_parametrize(
1121+
argnames, parametersets = ParameterSet._for_parametrize(
11221122
argnames,
11231123
argvalues,
11241124
self.function,
@@ -1150,8 +1150,8 @@ def parametrize(
11501150
if generated_ids is not None:
11511151
ids = generated_ids
11521152

1153-
ids = self._resolve_arg_ids(
1154-
argnames, ids, parameters, nodeid=self.definition.nodeid
1153+
ids = self._resolve_parameter_set_ids(
1154+
argnames, ids, parametersets, nodeid=self.definition.nodeid
11551155
)
11561156

11571157
# Store used (possibly generated) ids with parametrize Marks.
@@ -1163,7 +1163,9 @@ def parametrize(
11631163
# of all calls.
11641164
newcalls = []
11651165
for callspec in self._calls or [CallSpec2()]:
1166-
for param_index, (param_id, param_set) in enumerate(zip(ids, parameters)):
1166+
for param_index, (param_id, param_set) in enumerate(
1167+
zip(ids, parametersets)
1168+
):
11671169
newcallspec = callspec.setmulti(
11681170
valtypes=arg_values_types,
11691171
argnames=argnames,
@@ -1176,7 +1178,7 @@ def parametrize(
11761178
newcalls.append(newcallspec)
11771179
self._calls = newcalls
11781180

1179-
def _resolve_arg_ids(
1181+
def _resolve_parameter_set_ids(
11801182
self,
11811183
argnames: Sequence[str],
11821184
ids: Optional[
@@ -1185,18 +1187,23 @@ def _resolve_arg_ids(
11851187
Callable[[Any], Optional[object]],
11861188
]
11871189
],
1188-
parameters: Sequence[ParameterSet],
1190+
parametersets: Sequence[ParameterSet],
11891191
nodeid: str,
11901192
) -> List[str]:
1191-
"""Resolve the actual ids for the given argnames, based on the ``ids`` parameter given
1192-
to ``parametrize``.
1193+
"""Resolve the actual ids for the given parameter sets.
11931194
1194-
:param List[str] argnames: List of argument names passed to ``parametrize()``.
1195-
:param ids: The ids parameter of the parametrized call (see docs).
1196-
:param List[ParameterSet] parameters: The list of parameter values, same size as ``argnames``.
1197-
:param str str: The nodeid of the item that generated this parametrized call.
1198-
:rtype: List[str]
1199-
:returns: The list of ids for each argname given.
1195+
:param argnames:
1196+
Argument names passed to ``parametrize()``.
1197+
:param ids:
1198+
The `ids` parameter of the ``parametrize()`` call (see docs).
1199+
:param parametersets:
1200+
The parameter sets, each containing a set of values corresponding
1201+
to ``argnames``.
1202+
:param nodeid str:
1203+
The nodeid of the definition item that generated this
1204+
parametrization.
1205+
:returns:
1206+
List with ids for each parameter set given.
12001207
"""
12011208
if ids is None:
12021209
idfn = None
@@ -1206,8 +1213,8 @@ def _resolve_arg_ids(
12061213
ids_ = None
12071214
else:
12081215
idfn = None
1209-
ids_ = self._validate_ids(ids, parameters, self.function.__name__)
1210-
return idmaker(argnames, parameters, idfn, ids_, self.config, nodeid=nodeid)
1216+
ids_ = self._validate_ids(ids, parametersets, self.function.__name__)
1217+
return idmaker(argnames, parametersets, idfn, ids_, self.config, nodeid=nodeid)
12111218

12121219
def _validate_ids(
12131220
self,

0 commit comments

Comments
 (0)