From b8e874b546ac18a61564f9d89fb630f35e421116 Mon Sep 17 00:00:00 2001 From: joddeepesh-cloud Date: Sun, 28 Dec 2025 12:17:28 +0530 Subject: [PATCH 1/3] Fix scope resolution for parametrized fixtures using dict order --- src/_pytest/python.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 7374fa3cee0..3af5cbb078d 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1526,9 +1526,10 @@ def _find_parametrized_scope( if all_arguments_are_fixtures: fixturedefs = arg2fixturedefs or {} used_scopes = [ - fixturedef[-1]._scope - for name, fixturedef in fixturedefs.items() - if name in argnames + fixturedefs[name][-1] ._scope # correction part + for name in argnames + if name in fixturedefs + ] # Takes the most narrow scope from used fixtures. return min(used_scopes, default=Scope.Function) From 275a28d785a9c32384f748ff36e54f1ae084c63c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 28 Dec 2025 06:57:15 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytest/python.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 3af5cbb078d..a43443c2077 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1526,10 +1526,9 @@ def _find_parametrized_scope( if all_arguments_are_fixtures: fixturedefs = arg2fixturedefs or {} used_scopes = [ - fixturedefs[name][-1] ._scope # correction part + fixturedefs[name][-1]._scope # correction part for name in argnames if name in fixturedefs - ] # Takes the most narrow scope from used fixtures. return min(used_scopes, default=Scope.Function) From e4c453840baae61516cccc8083fc9c47b160cb00 Mon Sep 17 00:00:00 2001 From: joddeepesh-cloud Date: Sun, 28 Dec 2025 12:37:22 +0530 Subject: [PATCH 3/3] Add changrlog for issue #13503 --- changelog/13503.bugfix.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 changelog/13503.bugfix.rst diff --git a/changelog/13503.bugfix.rst b/changelog/13503.bugfix.rst new file mode 100644 index 00000000000..e69de29bb2d