From 4be79877a17cb483070f443363eaf0546f9fabfa Mon Sep 17 00:00:00 2001 From: Tan Long Date: Tue, 24 Nov 2026 15:02:54 +0800 Subject: [PATCH 1/3] decorate setUpClass() with @classmethod --- Lib/test/test_cmd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py index ed3336994edaeb..1793acca299a9f 100644 --- a/Lib/test/test_cmd.py +++ b/Lib/test/test_cmd.py @@ -271,7 +271,8 @@ def default(self, line): @support.requires_subprocess() class CmdTestReadline(unittest.TestCase): - def setUpClass(): + @classmethod + def setUpClass(cls): # Ensure that the readline module is loaded # If this fails, the test is skipped because SkipTest will be raised readline = import_module('readline') From 82cd6827d7c795c3c422164194d52627e4b41e7c Mon Sep 17 00:00:00 2001 From: Tan Long Date: Tue, 24 Nov 2026 15:41:55 +0800 Subject: [PATCH 2/3] rename `self` to `cls` --- Lib/test/test_dtrace.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_dtrace.py b/Lib/test/test_dtrace.py index ea5cc7c8871db0..97fa23cd38c936 100644 --- a/Lib/test/test_dtrace.py +++ b/Lib/test/test_dtrace.py @@ -454,8 +454,8 @@ class TraceTests: optimize_python = 0 @classmethod - def setUpClass(self): - self.backend.assert_usable() + def setUpClass(cls): + cls.backend.assert_usable() def run_case(self, name): actual_output, expected_output = self.backend.run_case( From f3dbe7fb07b3c7ffccd66f673b631ddd40b2ab88 Mon Sep 17 00:00:00 2001 From: Tan Long Date: Tue, 24 Nov 2026 16:01:20 +0800 Subject: [PATCH 3/3] change @staticmethod to @classmethod --- Lib/test/test_dbm_gnu.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py index 6980a702694803..45f6dd8faad05c 100644 --- a/Lib/test/test_dbm_gnu.py +++ b/Lib/test/test_dbm_gnu.py @@ -10,8 +10,8 @@ filename = TESTFN class TestGdbm(unittest.TestCase): - @staticmethod - def setUpClass(): + @classmethod + def setUpClass(cls): if support.verbose: print(f"gdbm version: {gdbm.gdbm_version}")