Skip to content

Commit

Permalink
use importlib_metadata for python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Jan 25, 2024
1 parent 805b1e8 commit 30b2987
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/unit/test_lower_bound_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

from contextlib import contextmanager
import importlib.metadata
from pathlib import Path
import re
import tempfile
Expand All @@ -22,6 +21,12 @@
from click.testing import CliRunner
import pytest

try:
import importlib.metadata as importlib_metadata
except:
# For Python 3.7 compatibility
import importlib_metadata

from test_utils.lower_bound_checker import lower_bound_checker

RUNNER = CliRunner()
Expand All @@ -38,7 +43,7 @@
def skip_test_if_not_installed(package_name: str):
"""Skips the current test if given package is not installed"""
try:
importlib.metadata.distribution(package_name)
importlib_metadata.distribution(package_name)
except importlib.metadata.PackageNotFoundError:
pytest.skip(f"Skipping test which requires {package_name} in `tests/unit/resources/` to be installed")

Expand Down

0 comments on commit 30b2987

Please sign in to comment.