[Python-checkins] gh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (GH-104226)

brettcannon webhook-mailer at python.org
Tue May 9 20:59:11 EDT 2023


https://github.com/python/cpython/commit/22f3425c3d3d896be0917d80d55e8abb08d99b18
commit: 22f3425c3d3d896be0917d80d55e8abb08d99b18
branch: main
author: sunmy2019 <59365878+sunmy2019 at users.noreply.github.com>
committer: brettcannon <brett at python.org>
date: 2023-05-10T00:59:04Z
summary:

gh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (GH-104226)

files:
M Lib/test/test_importlib/extension/test_loader.py

diff --git a/Lib/test/test_importlib/extension/test_loader.py b/Lib/test/test_importlib/extension/test_loader.py
index 3a74b821eaee..a7c6245825ff 100644
--- a/Lib/test/test_importlib/extension/test_loader.py
+++ b/Lib/test/test_importlib/extension/test_loader.py
@@ -262,15 +262,16 @@ def test_reload(self):
 
     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.



More information about the Python-checkins mailing list