Skip to content

Commit 5eaf84e

Browse files
authored
TST: use pytest.importorskip (#85)
1 parent bdb4df0 commit 5eaf84e

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

tests/test_at.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from collections.abc import Callable, Generator
22
from contextlib import contextmanager
33
from enum import Enum
4-
from importlib import import_module
54
from typing import cast
65

76
import numpy as np
@@ -40,12 +39,8 @@ def array(request: pytest.FixtureRequest) -> Array:
4039
x = np.asarray([10.0, 20.0, 30.0])
4140
x.flags.writeable = False
4241
else:
43-
library_name = library.value
44-
try:
45-
lib = import_module(library_name)
46-
except ImportError:
47-
pytest.skip(f"{library_name} is not installed")
48-
x = lib.asarray([10.0, 20.0, 30.0])
42+
xp = pytest.importorskip(library.value)
43+
x = xp.asarray([10.0, 20.0, 30.0])
4944
return x
5045

5146

0 commit comments

Comments
 (0)