Merge pull request #9531 from bluetech/misc
python: fix confused docstring of `Metafunc._resolve_arg_ids`
This commit is contained in:
commit
bb5a4e2d63
|
@ -992,8 +992,8 @@ class FixtureDef(Generic[FixtureValue]):
|
||||||
if exc:
|
if exc:
|
||||||
raise exc
|
raise exc
|
||||||
finally:
|
finally:
|
||||||
hook = self._fixturemanager.session.gethookproxy(request.node.path)
|
ihook = request.node.ihook
|
||||||
hook.pytest_fixture_post_finalizer(fixturedef=self, request=request)
|
ihook.pytest_fixture_post_finalizer(fixturedef=self, request=request)
|
||||||
# Even if finalization fails, we invalidate the cached fixture
|
# Even if finalization fails, we invalidate the cached fixture
|
||||||
# value and remove all finalizers because they may be bound methods
|
# value and remove all finalizers because they may be bound methods
|
||||||
# which will keep instances alive.
|
# which will keep instances alive.
|
||||||
|
@ -1027,8 +1027,8 @@ class FixtureDef(Generic[FixtureValue]):
|
||||||
self.finish(request)
|
self.finish(request)
|
||||||
assert self.cached_result is None
|
assert self.cached_result is None
|
||||||
|
|
||||||
hook = self._fixturemanager.session.gethookproxy(request.node.path)
|
ihook = request.node.ihook
|
||||||
result = hook.pytest_fixture_setup(fixturedef=self, request=request)
|
result = ihook.pytest_fixture_setup(fixturedef=self, request=request)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def cache_key(self, request: SubRequest) -> object:
|
def cache_key(self, request: SubRequest) -> object:
|
||||||
|
|
|
@ -1121,7 +1121,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,
|
||||||
|
@ -1153,8 +1153,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.
|
||||||
|
@ -1166,7 +1166,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,
|
||||||
|
@ -1179,7 +1181,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[
|
||||||
|
@ -1188,18 +1190,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
|
||||||
|
@ -1209,8 +1216,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,
|
||||||
|
|
Loading…
Reference in New Issue