From 3eb16b34be1900fe41d8b91e00facd62170e2878 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 23 Mar 2024 12:05:40 +0200 Subject: [PATCH] fixtures: stop using `request.param_index` in fixture cache key When `param` is not defined, `param_index` is always 0 (see `_compute_fixture_value`), so no point in using it besides adding some confusion. --- src/_pytest/fixtures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 48429a023..a8fed047e 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1072,7 +1072,7 @@ class FixtureDef(Generic[FixtureValue]): return result def cache_key(self, request: SubRequest) -> object: - return request.param_index if not hasattr(request, "param") else request.param + return getattr(request, "param", None) def __repr__(self) -> str: return f""