Skip to content

Commit

Permalink
bpo-44451: Reset DeprecationWarning filters in test_importlib.test_en…
Browse files Browse the repository at this point in the history
…try_points_by_index (GH-26784)

This avoids the following error if DeprecationWarnings are ignored.

    ======================================================================
    ERROR: test_entry_points_by_index (test.test_importlib.test_metadata_api.APITests)
    Prior versions of Distribution.entry_points would return a
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/builddir/build/BUILD/Python-3.10.0b3/Lib/test/test_importlib/test_metadata_api.py", line 145, in test_entry_points_by_index
        expected = next(iter(caught))
    StopIteration
    ----------------------------------------------------------------------
    Ran 1402 tests in 2.125s
    FAILED (errors=1, skipped=18, expected failures=1)
(cherry picked from commit df1502e)

Co-authored-by: Miro Hrončok <miro@hroncok.cz>
  • Loading branch information
miss-islington and hroncok committed Jun 18, 2021
1 parent bba7267 commit bf55a79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions Lib/test/test_importlib/test_metadata_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def test_entry_points_by_index(self):
"""
eps = distribution('distinfo-pkg').entry_points
with warnings.catch_warnings(record=True) as caught:
warnings.filterwarnings("default", category=DeprecationWarning)
eps[0]

# check warning
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Reset ``DeprecationWarning`` filters in
``test.test_importlib.test_metadata_api.APITests.test_entry_points_by_index``
to avoid ``StopIteration`` error if ``DeprecationWarnings`` are ignored.

0 comments on commit bf55a79

Please sign in to comment.