From 98a0a19bf30332946bc3e3b24c02cf43ae6c0528 Mon Sep 17 00:00:00 2001 From: crusaderky Date: Wed, 8 Jan 2025 12:32:49 +0000 Subject: [PATCH 1/2] TST: use pytest.importorskip --- tests/test_at.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/test_at.py b/tests/test_at.py index bd4e444a..db6b12e3 100644 --- a/tests/test_at.py +++ b/tests/test_at.py @@ -40,12 +40,8 @@ def array(request: pytest.FixtureRequest) -> Array: x = np.asarray([10.0, 20.0, 30.0]) x.flags.writeable = False else: - library_name = library.value - try: - lib = import_module(library_name) - except ImportError: - pytest.skip(f"{library_name} is not installed") - x = lib.asarray([10.0, 20.0, 30.0]) + xp = pytest.importorskip(library.value) + x = xp.asarray([10.0, 20.0, 30.0]) return x From 52e0c0ff51b88ab42f284ebf52cc66f1c02f9f3a Mon Sep 17 00:00:00 2001 From: crusaderky Date: Wed, 8 Jan 2025 12:35:00 +0000 Subject: [PATCH 2/2] lint --- tests/test_at.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_at.py b/tests/test_at.py index db6b12e3..24d356c0 100644 --- a/tests/test_at.py +++ b/tests/test_at.py @@ -1,7 +1,6 @@ from collections.abc import Callable, Generator from contextlib import contextmanager from enum import Enum -from importlib import import_module from typing import cast import numpy as np