Skip to content

Commit 8535856

Browse files
committed
Add test capturing missed expectation. Ref #300.
1 parent f794723 commit 8535856

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_api.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,22 @@ def test_entry_points_dict_construction(self):
133133
assert expected.category is DeprecationWarning
134134
assert "Construction of dict of EntryPoints is deprecated" in str(expected)
135135

136+
def test_entry_points_by_index(self):
137+
"""
138+
Prior versions of Distribution.entry_points would return a
139+
tuple that allowed access by index.
140+
Capture this now deprecated use-case
141+
See python/importlib_metadata#300 and bpo-44246.
142+
"""
143+
eps = distribution('distinfo-pkg').entry_points
144+
with warnings.catch_warnings(record=True) as caught:
145+
eps[0]
146+
147+
# check warning
148+
expected = next(iter(caught))
149+
assert expected.category is DeprecationWarning
150+
assert "Accessing entry points by index is deprecated" in str(expected)
151+
136152
def test_entry_points_groups_getitem(self):
137153
"""
138154
Prior versions of entry_points() returned a dict. Ensure

0 commit comments

Comments
 (0)