]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-103247: clear the module cache in a test in test_importlib/extensions/test_...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 10 May 2023 14:53:19 +0000 (07:53 -0700)
committerGitHub <noreply@github.com>
Wed, 10 May 2023 14:53:19 +0000 (07:53 -0700)
gh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (GH-104226)
(cherry picked from commit 22f3425c3d3d896be0917d80d55e8abb08d99b18)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Lib/test/test_importlib/extension/test_loader.py

index 8570c6bc90cd075cf9aff286a229b8b6d283c68a..8e2b58d12a39a39ffeddbf238cdbb39b776c5312 100644 (file)
@@ -179,15 +179,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.