mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.10] bpo-44246: Restore compatibility in entry_points (GH-26468) (GH-26471)
* [bpo-44246](): Entry points performance improvements.
From importlib_metadata 4.3.1.
* [bpo-44246](): Sync with importlib_metadata 4.4
(cherry picked from commit c34ed08d97)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Automerge-Triggered-By: GH:jaraco
This commit is contained in:
parent
d1480ad2f5
commit
7207203e1d
3 changed files with 125 additions and 1 deletions
|
|
@ -130,6 +130,22 @@ def test_entry_points_dict_construction(self):
|
|||
assert expected.category is DeprecationWarning
|
||||
assert "Construction of dict of EntryPoints is deprecated" in str(expected)
|
||||
|
||||
def test_entry_points_by_index(self):
|
||||
"""
|
||||
Prior versions of Distribution.entry_points would return a
|
||||
tuple that allowed access by index.
|
||||
Capture this now deprecated use-case
|
||||
See python/importlib_metadata#300 and bpo-44246.
|
||||
"""
|
||||
eps = distribution('distinfo-pkg').entry_points
|
||||
with warnings.catch_warnings(record=True) as caught:
|
||||
eps[0]
|
||||
|
||||
# check warning
|
||||
expected = next(iter(caught))
|
||||
assert expected.category is DeprecationWarning
|
||||
assert "Accessing entry points by index is deprecated" in str(expected)
|
||||
|
||||
def test_entry_points_groups_getitem(self):
|
||||
# Prior versions of entry_points() returned a dict. Ensure
|
||||
# that callers using '.__getitem__()' are supported but warned to
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue