Issue #14500: Fix importlib.test.import_.test_packages to clean up
after itself properly.
diff --git a/Lib/importlib/test/import_/test_packages.py b/Lib/importlib/test/import_/test_packages.py
index 9590d5f..58be433 100644
--- a/Lib/importlib/test/import_/test_packages.py
+++ b/Lib/importlib/test/import_/test_packages.py
@@ -3,6 +3,7 @@
import sys
import unittest
import importlib
+from test import support
class ParentModuleTests(unittest.TestCase):
@@ -38,7 +39,10 @@
module_code={'mod': module_injection})
with mock_modules as mock:
with util.import_state(meta_path=[mock]):
- submodule = import_util.import_(subname)
+ try:
+ submodule = import_util.import_(subname)
+ finally:
+ support.unload(subname)
def test_main():