summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-03-04 10:39:42 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2014-03-04 10:39:42 (GMT)
commitdc855b7b1f6c7e9a9eb73bcf2b50619f2dfaf703 (patch)
treedc09b03fac8694c964cf9e0df6e89cf55bb8d7ca /Lib/test
parentc913a7a6f68044584f7bee90ba85d5c27e7859fe (diff)
downloadcpython-dc855b7b1f6c7e9a9eb73bcf2b50619f2dfaf703.zip
cpython-dc855b7b1f6c7e9a9eb73bcf2b50619f2dfaf703.tar.gz
cpython-dc855b7b1f6c7e9a9eb73bcf2b50619f2dfaf703.tar.bz2
Close #20839: pkgutil.find_loader now uses importlib.util.find_spec
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_pkgutil.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py
index aaa9d8d..c4410a9 100644
--- a/Lib/test/test_pkgutil.py
+++ b/Lib/test/test_pkgutil.py
@@ -334,6 +334,25 @@ class ImportlibMigrationTests(unittest.TestCase):
self.assertIsNotNone(pkgutil.get_loader("test.support"))
self.assertEqual(len(w.warnings), 0)
+ def test_get_loader_handles_missing_loader_attribute(self):
+ global __loader__
+ this_loader = __loader__
+ del __loader__
+ try:
+ with check_warnings() as w:
+ self.assertIsNotNone(pkgutil.get_loader(__name__))
+ self.assertEqual(len(w.warnings), 0)
+ finally:
+ __loader__ = this_loader
+
+
+ def test_find_loader_avoids_emulation(self):
+ with check_warnings() as w:
+ self.assertIsNotNone(pkgutil.find_loader("sys"))
+ self.assertIsNotNone(pkgutil.find_loader("os"))
+ self.assertIsNotNone(pkgutil.find_loader("test.support"))
+ self.assertEqual(len(w.warnings), 0)
+
def test_get_importer_avoids_emulation(self):
# We use an illegal path so *none* of the path hooks should fire
with check_warnings() as w: