https://github.com/python/cpython/commit/eca3fe40c251d51964172dd4e6e9c7d0d85d7d4a
commit: eca3fe40c251d51964172dd4e6e9c7d0d85d7d4a
branch: main
author: Malcolm Smith <[email protected]>
committer: encukou <[email protected]>
date: 2024-09-06T15:23:55+02:00
summary:
gh-123780: Make test_pkgutil clean up `spam` module (GH-123036)
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]