From 8535856d43a45d81b93514aac874d58df14171b1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 30 May 2021 12:39:18 -0400 Subject: [PATCH] Add test capturing missed expectation. Ref #300. --- tests/test_api.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_api.py b/tests/test_api.py index b3c8c2f8..819d4841 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -133,6 +133,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