Skip to content

Commit dd4a955

Browse files
committed
Add a test
The test proves that the `source and` clause is needed in Distribution._read_egg_info_reqs(). Also, add a comment about the purpose of the third clause in the Distribution.metadata() method.
1 parent 212f471 commit dd4a955

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

importlib_metadata/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ def metadata(self):
198198
text = (
199199
self.read_text('METADATA')
200200
or self.read_text('PKG-INFO')
201+
# This last clause is here to support old egg-info files. Its
202+
# effect is to just end up using the PathDistribution's self._path
203+
# (which points to the egg-info file) attribute unchanged.
201204
or self.read_text('')
202205
)
203206
return _email_message_from_string(text)

importlib_metadata/tests/test_api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ def test_version_egg_info_file(self):
109109
version = importlib_metadata.version('egginfo-file')
110110
self.assertEqual(version, '0.1')
111111

112+
def test_requires_egg_info_file(self):
113+
requirements = importlib_metadata.requires('egginfo-file')
114+
self.assertIsNone(requirements)
115+
112116
def test_requires(self):
113117
deps = importlib_metadata.requires('egginfo-pkg')
114118
assert any(

0 commit comments

Comments
 (0)