summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pkgutil.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_pkgutil.py')
-rw-r--r--Lib/test/test_pkgutil.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py
index 1f48853..52dd0bc 100644
--- a/Lib/test/test_pkgutil.py
+++ b/Lib/test/test_pkgutil.py
@@ -208,9 +208,16 @@ class ExtendPathTests(unittest.TestCase):
importers = list(iter_importers(fullname))
expected_importer = get_importer(pathitem)
for finder in importers:
+ loader = finder.find_module(fullname)
+ try:
+ loader = loader.loader
+ except AttributeError:
+ # For now we still allow raw loaders from
+ # find_module().
+ pass
self.assertIsInstance(finder, importlib.machinery.FileFinder)
self.assertEqual(finder, expected_importer)
- self.assertIsInstance(finder.find_module(fullname),
+ self.assertIsInstance(loader,
importlib.machinery.SourceFileLoader)
self.assertIsNone(finder.find_module(pkgname))
@@ -222,8 +229,11 @@ class ExtendPathTests(unittest.TestCase):
finally:
shutil.rmtree(dirname)
del sys.path[0]
- del sys.modules['spam']
- del sys.modules['spam.eggs']
+ try:
+ del sys.modules['spam']
+ del sys.modules['spam.eggs']
+ except KeyError:
+ pass
def test_mixed_namespace(self):