From dc855b7b1f6c7e9a9eb73bcf2b50619f2dfaf703 Mon Sep 17 00:00:00 2001 From: Nick Coghlan Date: Tue, 4 Mar 2014 20:39:42 +1000 Subject: Close #20839: pkgutil.find_loader now uses importlib.util.find_spec --- Lib/test/test_pkgutil.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'Lib/test/test_pkgutil.py') diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py index aaa9d8df6b..c4410a9041 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: -- cgit v1.2.1