Skip to content

Commit

Permalink
replaced importorskip to all use safe_import
Browse files Browse the repository at this point in the history
  • Loading branch information
IvoVellekoop committed Oct 11, 2024
1 parent 45b3415 commit f2fa1e4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
12 changes: 7 additions & 5 deletions tests/test_camera.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import pytest

pytest.importorskip(
"harvesters",
reason="harvesters is required for the Camera module, install with pip install harvesters",
)
from ..openwfs.devices import Camera, safe_import

harvesters = safe_import("harvesters", "harvesters")
if not harvesters:
pytest.skip(
"harvesters is required for the Camera module, install with pip install harvesters", allow_module_level=True
)

from ..openwfs.devices import Camera

cti_path = R"C:\Program Files\Basler\pylon 7\Runtime\x64\ProducerU3V.cti"

Expand Down
12 changes: 8 additions & 4 deletions tests/test_scanning_microscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
import numpy as np
import pytest

pytest.importorskip(
"nidaqmx",
reason="nidaqmx is required for the ScanningMicroscope module, install with pip install nidaqmx",
)
from ..openwfs.devices import safe_import

nidaqmx = safe_import("nidaqmx", "nidaq")
if not nidaqmx:
pytest.skip(
"nidaqmx is required for the ScanningMicroscope module, install with pip install nidaqmx",
allow_module_level=True,
)

from ..openwfs.devices import ScanningMicroscope, Axis
from ..openwfs.devices.galvo_scanner import InputChannel
Expand Down
10 changes: 7 additions & 3 deletions tests/test_slm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
import cv2
import pytest

pytest.importorskip("glfw", reason="GLFW is required for the ScanningMicroscope module")
pytest.importorskip("OpenGL.GL", reason="PyOpenGL is required for OpenGL rendering")
from ..openwfs.devices import safe_import

glfw = safe_import("glfw", "glfw")
OpenGL = safe_import("OpenGL", "OpenGL")
if not glfw or not OpenGL:
pytest.skip("GLFW and PyOpenGL are required for the test_slm module", allow_module_level=True)


import glfw
import numpy as np # for debugging


Expand Down

0 comments on commit f2fa1e4

Please sign in to comment.