mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-113174: Sync with importlib_metadata 7.0 (#113175)
* Sync with importlib_metadata 7.0.0 * Add blurb * Update docs to reflect changes. * Link datamodel docs for object.__getitem__ Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> * Add what's new for removed __getattr__ * Link datamodel docs for object.__getitem__ Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> * Add exclamation point, as that seems to be used for other classes. --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
6b70c3dc5a
commit
2d91409c69
10 changed files with 267 additions and 146 deletions
|
@ -12,6 +12,7 @@ except ImportError:
|
|||
|
||||
from . import fixtures
|
||||
from ._context import suppress
|
||||
from ._path import Symlink
|
||||
from importlib.metadata import (
|
||||
Distribution,
|
||||
EntryPoint,
|
||||
|
@ -68,7 +69,7 @@ class BasicTests(fixtures.DistInfoPkg, unittest.TestCase):
|
|||
dict(name=''),
|
||||
)
|
||||
def test_invalid_inputs_to_from_name(self, name):
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises(Exception):
|
||||
Distribution.from_name(name)
|
||||
|
||||
|
||||
|
@ -207,6 +208,20 @@ class DiscoveryTests(
|
|||
with self.assertRaises(ValueError):
|
||||
list(distributions(context='something', name='else'))
|
||||
|
||||
def test_interleaved_discovery(self):
|
||||
"""
|
||||
Ensure interleaved searches are safe.
|
||||
|
||||
When the search is cached, it is possible for searches to be
|
||||
interleaved, so make sure those use-cases are safe.
|
||||
|
||||
Ref #293
|
||||
"""
|
||||
dists = distributions()
|
||||
next(dists)
|
||||
version('egginfo-pkg')
|
||||
next(dists)
|
||||
|
||||
|
||||
class DirectoryTest(fixtures.OnSysPath, fixtures.SiteDir, unittest.TestCase):
|
||||
def test_egg_info(self):
|
||||
|
@ -388,6 +403,27 @@ class PackagesDistributionsTest(
|
|||
|
||||
assert not any(name.endswith('.dist-info') for name in distributions)
|
||||
|
||||
def test_packages_distributions_symlinked_top_level(self) -> None:
|
||||
"""
|
||||
Distribution is resolvable from a simple top-level symlink in RECORD.
|
||||
See #452.
|
||||
"""
|
||||
|
||||
files: fixtures.FilesSpec = {
|
||||
"symlinked_pkg-1.0.0.dist-info": {
|
||||
"METADATA": """
|
||||
Name: symlinked-pkg
|
||||
Version: 1.0.0
|
||||
""",
|
||||
"RECORD": "symlinked,,\n",
|
||||
},
|
||||
".symlink.target": {},
|
||||
"symlinked": Symlink(".symlink.target"),
|
||||
}
|
||||
|
||||
fixtures.build_files(files, self.site_dir)
|
||||
assert packages_distributions()['symlinked'] == ['symlinked-pkg']
|
||||
|
||||
|
||||
class PackagesDistributionsEggTest(
|
||||
fixtures.EggInfoPkg,
|
||||
|
@ -424,3 +460,10 @@ class PackagesDistributionsEggTest(
|
|||
# sources_fallback-pkg has one import ('sources_fallback') inferred from
|
||||
# SOURCES.txt (top_level.txt and installed-files.txt is missing)
|
||||
assert import_names_from_package('sources_fallback-pkg') == {'sources_fallback'}
|
||||
|
||||
|
||||
class EditableDistributionTest(fixtures.DistInfoPkgEditable, unittest.TestCase):
|
||||
def test_origin(self):
|
||||
dist = Distribution.from_name('distinfo-pkg')
|
||||
assert dist.origin.url.endswith('.whl')
|
||||
assert dist.origin.archive_info.hashes.sha256
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue