https://github.com/python/cpython/commit/72cdd2ade6df5512a578716e64b812d6fe4f06e5 commit: 72cdd2ade6df5512a578716e64b812d6fe4f06e5 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: Yhg1s <[email protected]> date: 2024-09-06T22:57:46+02:00 summary:
[3.13] gh-123780: Make test_pkgutil clean up `spam` module (GH-123036) (#123781) gh-123780: Make test_pkgutil clean up `spam` module (GH-123036) (cherry picked from commit eca3fe40c251d51964172dd4e6e9c7d0d85d7d4a) Co-authored-by: Malcolm Smith <[email protected]> files: M Lib/test/test_pkgutil.py diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py index 20fba87e4ec120..ca6927554b053c 100644 --- a/Lib/test/test_pkgutil.py +++ b/Lib/test/test_pkgutil.py @@ -624,8 +624,11 @@ def test_get_loader_handles_missing_spec_attribute(self): mod = type(sys)(name) del mod.__spec__ with CleanImport(name): - sys.modules[name] = mod - loader = pkgutil.get_loader(name) + try: + sys.modules[name] = mod + loader = pkgutil.get_loader(name) + finally: + sys.modules.pop(name, None) self.assertIsNone(loader) @ignore_warnings(category=DeprecationWarning) @@ -634,8 +637,11 @@ def test_get_loader_handles_spec_attribute_none(self): mod = type(sys)(name) mod.__spec__ = None with CleanImport(name): - sys.modules[name] = mod - loader = pkgutil.get_loader(name) + try: + sys.modules[name] = mod + loader = pkgutil.get_loader(name) + finally: + sys.modules.pop(name, None) self.assertIsNone(loader) @ignore_warnings(category=DeprecationWarning) _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
