Skip to content

Commit

Permalink
pythongh-103247: clear the module cache in a test in test_importlib/e…
Browse files Browse the repository at this point in the history
…xtensions/test_loader.py (pythonGH-104226)

(cherry picked from commit 22f3425)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
  • Loading branch information
sunmy2019 authored and miss-islington committed May 10, 2023
1 parent 2fa14d4 commit 06a0974
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Lib/test/test_importlib/extension/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,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.
Expand Down

0 comments on commit 06a0974

Please sign in to comment.