From 84a342e27c1b3ba218b9c31ed9aeddba843ef36c Mon Sep 17 00:00:00 2001 From: Christoph Anton Mitterer Date: Sun, 6 Aug 2023 17:39:31 +0200 Subject: [PATCH 1/2] doc: parametrize() can be called multiple times only on different args Signed-off-by: Christoph Anton Mitterer --- src/_pytest/python.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index c0c16d4d0..b3f7d408b 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1239,8 +1239,9 @@ class Metafunc: during the collection phase. If you need to setup expensive resources see about setting indirect to do it rather than at test setup time. - Can be called multiple times, in which case each call parametrizes all - previous parametrizations, e.g. + Can be called multiple times per test function (but only on different + argument names), in which case each call parametrizes all previous + parametrizations, e.g. :: From 1cc58ed67ff9e9c90b6b39154763138779ebceaf Mon Sep 17 00:00:00 2001 From: Christoph Anton Mitterer Date: Sun, 6 Aug 2023 17:43:37 +0200 Subject: [PATCH 2/2] improve exception message on duplicate parametrization Signed-off-by: Christoph Anton Mitterer --- src/_pytest/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index b3f7d408b..fef952b66 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1148,7 +1148,7 @@ class CallSpec2: arg2scope = self._arg2scope.copy() for arg, val in zip(argnames, valset): if arg in params or arg in funcargs: - raise ValueError(f"duplicate {arg!r}") + raise ValueError(f"duplicate parametrization of {arg!r}") valtype_for_arg = valtypes[arg] if valtype_for_arg == "params": params[arg] = val