mirror of
https://github.com/python/cpython.git
synced 2025-11-03 15:11:34 +00:00
bpo-46126: Restore docstrings in importlib.metadata tests. (#32288)
This commit is contained in:
parent
3289209716
commit
67712e71b3
2 changed files with 44 additions and 24 deletions
|
|
@ -37,10 +37,12 @@ def test_for_name_does_not_exist(self):
|
|||
Distribution.from_name('does-not-exist')
|
||||
|
||||
def test_package_not_found_mentions_metadata(self):
|
||||
# When a package is not found, that could indicate that the
|
||||
# packgae is not installed or that it is installed without
|
||||
# metadata. Ensure the exception mentions metadata to help
|
||||
# guide users toward the cause. See #124.
|
||||
"""
|
||||
When a package is not found, that could indicate that the
|
||||
packgae is not installed or that it is installed without
|
||||
metadata. Ensure the exception mentions metadata to help
|
||||
guide users toward the cause. See #124.
|
||||
"""
|
||||
with self.assertRaises(PackageNotFoundError) as ctx:
|
||||
Distribution.from_name('does-not-exist')
|
||||
|
||||
|
|
@ -89,8 +91,10 @@ def pkg_with_dashes(site_dir):
|
|||
return 'my-pkg'
|
||||
|
||||
def test_dashes_in_dist_name_found_as_underscores(self):
|
||||
# For a package with a dash in the name, the dist-info metadata
|
||||
# uses underscores in the name. Ensure the metadata loads.
|
||||
"""
|
||||
For a package with a dash in the name, the dist-info metadata
|
||||
uses underscores in the name. Ensure the metadata loads.
|
||||
"""
|
||||
pkg_name = self.pkg_with_dashes(self.site_dir)
|
||||
assert version(pkg_name) == '1.0'
|
||||
|
||||
|
|
@ -108,7 +112,9 @@ def pkg_with_mixed_case(site_dir):
|
|||
return 'CherryPy'
|
||||
|
||||
def test_dist_name_found_as_any_case(self):
|
||||
# Ensure the metadata loads when queried with any case.
|
||||
"""
|
||||
Ensure the metadata loads when queried with any case.
|
||||
"""
|
||||
pkg_name = self.pkg_with_mixed_case(self.site_dir)
|
||||
assert version(pkg_name) == '1.0'
|
||||
assert version(pkg_name.lower()) == '1.0'
|
||||
|
|
@ -244,11 +250,13 @@ def test_repr(self):
|
|||
assert "'name'" in repr(self.ep)
|
||||
|
||||
def test_hashable(self):
|
||||
# EntryPoints should be hashable.
|
||||
"""EntryPoints should be hashable"""
|
||||
hash(self.ep)
|
||||
|
||||
def test_json_dump(self):
|
||||
# json should not expect to be able to dump an EntryPoint.
|
||||
"""
|
||||
json should not expect to be able to dump an EntryPoint
|
||||
"""
|
||||
with self.assertRaises(Exception):
|
||||
with warnings.catch_warnings(record=True):
|
||||
json.dumps(self.ep)
|
||||
|
|
@ -260,7 +268,9 @@ def test_attr(self):
|
|||
assert self.ep.attr is None
|
||||
|
||||
def test_sortable(self):
|
||||
# EntryPoint objects are sortable, but result is undefined.
|
||||
"""
|
||||
EntryPoint objects are sortable, but result is undefined.
|
||||
"""
|
||||
sorted(
|
||||
[
|
||||
EntryPoint(name='b', value='val', group='group'),
|
||||
|
|
@ -273,8 +283,10 @@ class FileSystem(
|
|||
fixtures.OnSysPath, fixtures.SiteDir, fixtures.FileBuilder, unittest.TestCase
|
||||
):
|
||||
def test_unicode_dir_on_sys_path(self):
|
||||
# Ensure a Unicode subdirectory of a directory on sys.path
|
||||
# does not crash.
|
||||
"""
|
||||
Ensure a Unicode subdirectory of a directory on sys.path
|
||||
does not crash.
|
||||
"""
|
||||
fixtures.build_files(
|
||||
{self.unicode_filename(): {}},
|
||||
prefix=self.site_dir,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue