[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 22f3425c3d)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2023-05-10 07:53:19 -07:00 committed by GitHub
parent a8e902d2c2
commit 1cbf844875
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View 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.