bpo-39791: Refresh importlib.metadata from importlib_metadata 1.6.1. (GH-20659)

* Refresh importlib.metadata from importlib_metadata 1.6.1.

* 📜🤖 Added by blurb_it.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
This commit is contained in:
Jason R. Coombs 2020-06-05 16:34:16 -04:00 committed by GitHub
parent 5fe1df1886
commit 161541ab45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 84 additions and 18 deletions

View file

@ -3,9 +3,10 @@ import unittest
from contextlib import ExitStack
from importlib.metadata import (
distribution, entry_points, files, PackageNotFoundError, version,
distribution, entry_points, files, PackageNotFoundError,
version, distributions,
)
from importlib.resources import path
from importlib import resources
from test.support import requires_zlib
@ -14,15 +15,19 @@ from test.support import requires_zlib
class TestZip(unittest.TestCase):
root = 'test.test_importlib.data'
def _fixture_on_path(self, filename):
pkg_file = resources.files(self.root).joinpath(filename)
file = self.resources.enter_context(resources.as_file(pkg_file))
assert file.name.startswith('example-'), file.name
sys.path.insert(0, str(file))
self.resources.callback(sys.path.pop, 0)
def setUp(self):
# Find the path to the example-*.whl so we can add it to the front of
# sys.path, where we'll then try to find the metadata thereof.
self.resources = ExitStack()
self.addCleanup(self.resources.close)
wheel = self.resources.enter_context(
path(self.root, 'example-21.12-py3-none-any.whl'))
sys.path.insert(0, str(wheel))
self.resources.callback(sys.path.pop, 0)
self._fixture_on_path('example-21.12-py3-none-any.whl')
def test_zip_version(self):
self.assertEqual(version('example'), '21.12')
@ -49,6 +54,10 @@ class TestZip(unittest.TestCase):
path = str(file.dist.locate_file(file))
assert '.whl/' in path, path
def test_one_distribution(self):
dists = list(distributions(path=sys.path[:1]))
assert len(dists) == 1
@requires_zlib()
class TestEgg(TestZip):
@ -57,10 +66,7 @@ class TestEgg(TestZip):
# sys.path, where we'll then try to find the metadata thereof.
self.resources = ExitStack()
self.addCleanup(self.resources.close)
egg = self.resources.enter_context(
path(self.root, 'example-21.12-py3.6.egg'))
sys.path.insert(0, str(egg))
self.resources.callback(sys.path.pop, 0)
self._fixture_on_path('example-21.12-py3.6.egg')
def test_files(self):
for file in files('example'):