bpo-44893: Implement EntryPoint as simple class with attributes. (GH-30150)

* bpo-44893: Implement EntryPoint as simple class and deprecate tuple access in favor of attribute access. Syncs with importlib_metadata 4.8.1.

* Apply refactorings found in importlib_metadata 4.8.2.
This commit is contained in:
Jason R. Coombs 2021-12-16 15:49:42 -05:00 committed by GitHub
parent 109d966021
commit 04deaee4c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 267 additions and 106 deletions

View file

@ -1,7 +1,7 @@
import sys
import unittest
from contextlib import ExitStack
from . import fixtures
from importlib.metadata import (
PackageNotFoundError,
distribution,
@ -10,27 +10,11 @@ from importlib.metadata import (
files,
version,
)
from importlib import resources
from test.support import requires_zlib
@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)
class TestZip(fixtures.ZipFixtures, unittest.TestCase):
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)
super().setUp()
self._fixture_on_path('example-21.12-py3-none-any.whl')
def test_zip_version(self):
@ -63,13 +47,9 @@ class TestZip(unittest.TestCase):
assert len(dists) == 1
@requires_zlib()
class TestEgg(TestZip):
def setUp(self):
# Find the path to the example-*.egg 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)
super().setUp()
self._fixture_on_path('example-21.12-py3.6.egg')
def test_files(self):