]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-103247: clear the module cache in a test in test_importlib/extensions/test_loader...
authorsunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Wed, 10 May 2023 00:59:04 +0000 (08:59 +0800)
committerGitHub <noreply@github.com>
Wed, 10 May 2023 00:59:04 +0000 (00:59 +0000)
Lib/test/test_importlib/extension/test_loader.py

index 3a74b821eaee495a66f7d9e32e9935885f31a8e7..a7c6245825ff868ecb74eb2aae3c206221471fe0 100644 (file)
@@ -262,15 +262,16 @@ class MultiPhaseExtensionModuleTests(abc.LoaderTests):
 
     def test_try_registration(self):
         # Assert that the PyState_{Find,Add,Remove}Module C API doesn't work.
-        module = self.load_module()
-        with self.subTest('PyState_FindModule'):
-            self.assertEqual(module.call_state_registration_func(0), None)
-        with self.subTest('PyState_AddModule'):
-            with self.assertRaises(SystemError):
-                module.call_state_registration_func(1)
-        with self.subTest('PyState_RemoveModule'):
-            with self.assertRaises(SystemError):
-                module.call_state_registration_func(2)
+        with util.uncache(self.name):
+            module = self.load_module()
+            with self.subTest('PyState_FindModule'):
+                self.assertEqual(module.call_state_registration_func(0), None)
+            with self.subTest('PyState_AddModule'):
+                with self.assertRaises(SystemError):
+                    module.call_state_registration_func(1)
+            with self.subTest('PyState_RemoveModule'):
+                with self.assertRaises(SystemError):
+                    module.call_state_registration_func(2)
 
     def test_load_submodule(self):
         # Test loading a simulated submodule.