Skip to content

Commit

Permalink
Suppress warning when CustomDistribution, derived from importlib.meta…
Browse files Browse the repository at this point in the history
…data, is present.
  • Loading branch information
jaraco committed Sep 11, 2024
1 parent 7290346 commit 460a826
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/compat/test_py39_compat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import contextlib
import pathlib
import sys
import unittest
import warnings

from importlib_metadata import (
distribution,
Expand Down Expand Up @@ -63,6 +65,9 @@ def test_compatibility_with_old_stdlib_path_distribution(self):
Ref python/importlib_metadata#396.
"""
self.fixtures.enter_context(fixtures.install_finder(self._meta_path_finder()))
self.fixtures.enter_context(
suppress_unrecognized_distribution_subclass_warning()
)

assert list(distributions())
assert distribution("distinfo_pkg")
Expand All @@ -72,3 +77,15 @@ def test_compatibility_with_old_stdlib_path_distribution(self):
assert list(metadata("distinfo_pkg"))
assert list(metadata("distinfo_pkg_custom"))
assert list(entry_points(group="entries"))


@contextlib.contextmanager
def suppress_unrecognized_distribution_subclass_warning():
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
category=UserWarning,
message="Unrecognized distribution subclass",
append=True,
)
yield

0 comments on commit 460a826

Please sign in to comment.