bpo-37697: Sync with importlib_metadata 0.19 (#14993)

* bpo-37697: Sync with importlib_metadata 0.19

* Run make regen-importlib

* 📜🤖 Added by blurb_it.
This commit is contained in:
Jason R. Coombs 2019-07-28 14:59:24 -04:00 committed by GitHub
parent b222955355
commit 049460da9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 841 additions and 794 deletions

View file

@ -32,7 +32,7 @@ class BasicTests(fixtures.DistInfoPkg, unittest.TestCase):
class ImportTests(fixtures.DistInfoPkg, unittest.TestCase):
def test_import_nonexistent_module(self):
# Ensure that the MetadataPathFinder does not crash an import of a
# nonexistent module.
# non-existant module.
with self.assertRaises(ImportError):
importlib.import_module('does_not_exist')
@ -41,6 +41,11 @@ class ImportTests(fixtures.DistInfoPkg, unittest.TestCase):
ep = entries['main']
self.assertEqual(ep.load().__name__, "main")
def test_entrypoint_with_colon_in_name(self):
entries = dict(entry_points()['entries'])
ep = entries['ns:sub']
self.assertEqual(ep.value, 'mod:main')
def test_resolve_without_attr(self):
ep = EntryPoint(
name='ep',
@ -159,8 +164,16 @@ class DiscoveryTests(fixtures.EggInfoPkg,
class DirectoryTest(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase):
def test(self):
def test_egg_info(self):
# make an `EGG-INFO` directory that's unrelated
self.site_dir.joinpath('EGG-INFO').mkdir()
# used to crash with `IsADirectoryError`
self.assertIsNone(version('unknown-package'))
with self.assertRaises(PackageNotFoundError):
version('unknown-package')
def test_egg(self):
egg = self.site_dir.joinpath('foo-3.6.egg')
egg.mkdir()
with self.add_sys_path(egg):
with self.assertRaises(PackageNotFoundError):
version('foo')