From 34142cd8880a06151ee331ce5ed05f60eb650e95 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 14 May 2019 10:02:00 -0400 Subject: [PATCH] Apply changes from importlib_metadata 0.12. --- Lib/importlib/_bootstrap_external.py | 2 +- Lib/test/test_importlib/test_zip.py | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index b111ea3163f3..45fd087c5fe4 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -1359,7 +1359,7 @@ class PathFinder: return None return spec.loader - search_template = r'{pattern}(-.*)?\.(dist|egg)-info' + search_template = r'(?:{pattern}(-.*)?\.(dist|egg)-info|EGG-INFO)' @classmethod def find_distributions(cls, name=None, path=None): diff --git a/Lib/test/test_importlib/test_zip.py b/Lib/test/test_importlib/test_zip.py index c7c8c0b1843b..9b6bce0d4c2f 100644 --- a/Lib/test/test_importlib/test_zip.py +++ b/Lib/test/test_importlib/test_zip.py @@ -6,13 +6,9 @@ from importlib.metadata import distribution, entry_points, files, version from importlib.resources import path -class BespokeLoader: - archive = 'bespoke' - - class TestZip(unittest.TestCase): def setUp(self): - # Find the path to the example.*.whl so we can add it to the front of + # 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) @@ -40,3 +36,21 @@ class TestZip(unittest.TestCase): for file in files('example'): path = str(file.dist.locate_file(file)) assert '.whl/' in path, path + + +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) + egg = self.resources.enter_context( + path('importlib_metadata.tests.data', + 'example-21.12-py3.6.egg')) + sys.path.insert(0, str(egg)) + self.resources.callback(sys.path.pop, 0) + + def test_files(self): + for file in files('example'): + path = str(file.dist.locate_file(file)) + assert '.egg/' in path, path -- 2.47.3