From 1a9385c441f6868de94775511a63c1bf7c6c5081 Mon Sep 17 00:00:00 2001 From: michmli Date: Fri, 21 Apr 2023 17:55:39 -0400 Subject: [PATCH] Added feature for Issue 10819 --- AUTHORS | 2 ++ src/_pytest/fixtures.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/AUTHORS b/AUTHORS index 058236461..6ace3b6a4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -394,3 +394,5 @@ Zachary OBrien Zhouxin Qiu Zoltán Máté Zsolt Cserna +Michelle Li +Yuanshu Wang diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 007245b24..c95b4f16f 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1653,6 +1653,11 @@ class FixtureManager: faclist.insert(i, fixture_def) if marker.autouse: autousenames.append(name) + if marker.scope == "class": + for parentnodeid in nodes.iterparentnodeids(nodeid): + basenames = self._nodeid_autousenames.get(parentnodeid) + if basenames: + autousenames.append(str(basenames)) if autousenames: self._nodeid_autousenames.setdefault(nodeid or "", []).extend(autousenames)