mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Close #20839: pkgutil.find_loader now uses importlib.util.find_spec
This commit is contained in:
parent
c913a7a6f6
commit
dc855b7b1f
4 changed files with 37 additions and 20 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue