Skip to content

Commit e4e555d

Browse files
committed
Add test capturing expectation that users should receive a hint as to the cause of a PackageNotFoundError if the package metadata is missing. Ref #124.
1 parent 2cb809a commit e4e555d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

importlib_metadata/tests/test_main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ def test_for_name_does_not_exist(self):
3535
with self.assertRaises(PackageNotFoundError):
3636
Distribution.from_name('does-not-exist')
3737

38+
def test_package_not_found_mentions_metadata(self):
39+
"""
40+
When a package is not found, that could indicate that the
41+
packgae is not installed or that it is installed without
42+
metadata. Ensure the exception mentions metadata to help
43+
guide users toward the cause. See #124.
44+
"""
45+
with self.assertRaises(PackageNotFoundError) as ctx:
46+
Distribution.from_name('does-not-exist')
47+
48+
assert "metadata" in str(ctx.exception)
49+
3850
def test_new_style_classes(self):
3951
self.assertIsInstance(Distribution, type)
4052
self.assertIsInstance(MetadataPathFinder, type)

0 commit comments

Comments
 (0)