Fix circular reference in CustomTestCase.__init_subclass__ (#21650)

Co-authored-by: wan4ch <wan4ch@gmail.com>
This commit is contained in:
Liangsheng Yin
2026-03-29 20:38:12 -07:00
committed by GitHub
co-authored by wan4ch
parent afb32d7622
commit c06ca1526c
+4 -2
View File
@@ -2068,9 +2068,11 @@ class CustomTestCase(unittest.TestCase):
if getattr(setup, "_safe_setup_wrapped", False):
return
def safe_setUpClass(klass, _orig=setup):
orig_func = setup.__func__
def safe_setUpClass(klass):
try:
_orig.__func__(klass)
orig_func(klass)
except Exception:
# Best-effort cleanup; suppress teardown errors so the
# original setUpClass exception propagates clearly.