Skip to content

Commit 30407eb

Browse files
committed
python: pinpoint nodeid in a couple of parametrization errors
1 parent 0ccb579 commit 30407eb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/_pytest/python.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,14 +1073,15 @@ def setmulti(
10731073
marks: Iterable[Mark | MarkDecorator],
10741074
scope: Scope,
10751075
param_index: int,
1076+
nodeid: str,
10761077
) -> CallSpec2:
10771078
params = self.params.copy()
10781079
indices = self.indices.copy()
10791080
arg2scope = dict(self._arg2scope)
10801081
for arg, val in zip(argnames, valset):
10811082
if arg in params:
10821083
raise nodes.Collector.CollectError(
1083-
f"duplicate parametrization of {arg!r}"
1084+
f"{nodeid}: duplicate parametrization of {arg!r}"
10841085
)
10851086
params[arg] = val
10861087
indices[arg] = param_index
@@ -1235,6 +1236,8 @@ def parametrize(
12351236
It will also override any fixture-function defined scope, allowing
12361237
to set a dynamic scope using test context or configuration.
12371238
"""
1239+
nodeid = self.definition.nodeid
1240+
12381241
argnames, parametersets = ParameterSet._for_parametrize(
12391242
argnames,
12401243
argvalues,
@@ -1246,7 +1249,7 @@ def parametrize(
12461249

12471250
if "request" in argnames:
12481251
fail(
1249-
"'request' is a reserved name and cannot be used in @pytest.mark.parametrize",
1252+
f"{nodeid}: 'request' is a reserved name and cannot be used in @pytest.mark.parametrize",
12501253
pytrace=False,
12511254
)
12521255

@@ -1341,6 +1344,7 @@ def parametrize(
13411344
marks=param_set.marks,
13421345
scope=scope_,
13431346
param_index=param_index,
1347+
nodeid=nodeid,
13441348
)
13451349
newcalls.append(newcallspec)
13461350
self._calls = newcalls

0 commit comments

Comments
 (0)