From c06ca1526cb6008a8dacb4fdb06567e648134664 Mon Sep 17 00:00:00 2001 From: Liangsheng Yin Date: Sun, 29 Mar 2026 20:38:12 -0700 Subject: [PATCH] Fix circular reference in CustomTestCase.__init_subclass__ (#21650) Co-authored-by: wan4ch --- python/sglang/test/test_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/sglang/test/test_utils.py b/python/sglang/test/test_utils.py index 44f4e010a..6c6c29be7 100644 --- a/python/sglang/test/test_utils.py +++ b/python/sglang/test/test_utils.py @@ -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.