]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-152391: Improve `test_interpreters.test_stress` test (#152396)
authorsobolevn <mail@sobolevn.me>
Sat, 27 Jun 2026 15:12:22 +0000 (18:12 +0300)
committerGitHub <noreply@github.com>
Sat, 27 Jun 2026 15:12:22 +0000 (18:12 +0300)
Lib/test/test_interpreters/test_stress.py

index 50d87a6ccd3cadb40dae05c182f2ca86cb5891ed..50d2444a4c72d3100f996c12efb08bf1ba11c49d 100644 (file)
@@ -25,6 +25,7 @@ class StressTests(TestBase):
         del alive
         support.gc_collect()
 
+    @threading_helper.requires_working_threading()
     @support.bigmemtest(size=200, memuse=32*2**20, dry_run=False)
     def test_create_many_threaded(self, size):
         alive = []
@@ -80,9 +81,12 @@ class StressTests(TestBase):
         import _testcapi
 
         assertion = self.assertRaises(InterpreterError)
-        _testcapi.set_nomemory(0, 1)
-        with assertion:
-            _interpreters.create()
+        try:
+            _testcapi.set_nomemory(0, 1)
+            with assertion:
+                _interpreters.create()
+        finally:
+            _testcapi.remove_mem_hooks()
 
 
 if __name__ == '__main__':