Skip to content

Commit 1cbf844

Browse files
[3.11] gh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (GH-104226) (#104345)
gh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (GH-104226) (cherry picked from commit 22f3425) Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
1 parent a8e902d commit 1cbf844

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Lib/test/test_importlib/extension/test_loader.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,16 @@ def test_reload(self):
179179

180180
def test_try_registration(self):
181181
# Assert that the PyState_{Find,Add,Remove}Module C API doesn't work.
182-
module = self.load_module()
183-
with self.subTest('PyState_FindModule'):
184-
self.assertEqual(module.call_state_registration_func(0), None)
185-
with self.subTest('PyState_AddModule'):
186-
with self.assertRaises(SystemError):
187-
module.call_state_registration_func(1)
188-
with self.subTest('PyState_RemoveModule'):
189-
with self.assertRaises(SystemError):
190-
module.call_state_registration_func(2)
182+
with util.uncache(self.name):
183+
module = self.load_module()
184+
with self.subTest('PyState_FindModule'):
185+
self.assertEqual(module.call_state_registration_func(0), None)
186+
with self.subTest('PyState_AddModule'):
187+
with self.assertRaises(SystemError):
188+
module.call_state_registration_func(1)
189+
with self.subTest('PyState_RemoveModule'):
190+
with self.assertRaises(SystemError):
191+
module.call_state_registration_func(2)
191192

192193
def test_load_submodule(self):
193194
# Test loading a simulated submodule.

0 commit comments

Comments
 (0)