Apply changes from importlib_metadata 0.12.

This commit is contained in:
Jason R. Coombs 2019-05-14 10:02:00 -04:00
parent 7f9924a6d7
commit 34142cd888
2 changed files with 20 additions and 6 deletions

View file

@ -1359,7 +1359,7 @@ def find_module(cls, fullname, path=None):
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):

View file

@ -6,13 +6,9 @@
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 @@ def test_files(self):
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