Skip to content

Commit 93df153

Browse files
committed
Skip test for hyperspy version not using the file_handle API
1 parent 15a8864 commit 93df153

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

rsciio/tests/test_emd_ncem.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@
2727

2828
import numpy as np
2929
import pytest
30+
from packaging.version import Version
3031

3132
h5py = pytest.importorskip("h5py", reason="h5py not installed")
3233
hs = pytest.importorskip("hyperspy.api", reason="hyperspy not installed")
3334

35+
import hyperspy # noqa: E402
36+
3437
TEST_DATA_PATH = Path(__file__).parent / "data" / "emd"
3538

3639

@@ -51,6 +54,10 @@
5154
test_title = "This is a test!"
5255

5356

57+
@pytest.mark.skipif(
58+
Version(hyperspy.__version__) <= Version("2.3.0"),
59+
reason="HyperSpy > 2.3.0 required.",
60+
)
5461
@pytest.mark.parametrize("lazy", (False, True))
5562
def test_signal_3d_loading(lazy):
5663
signal = hs.load(TEST_DATA_PATH / "example_signal.emd", lazy=lazy)

rsciio/tests/test_emd_velox.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030
import numpy as np
3131
import pytest
3232
from dateutil import tz
33+
from packaging.version import Version
3334

3435
from rsciio.utils.tests import assert_deep_almost_equal
3536

3637
hs = pytest.importorskip("hyperspy.api", reason="hyperspy not installed")
3738
pytest.importorskip("sparse")
3839

40+
import hyperspy # noqa: E402
3941

4042
TEST_DATA_PATH = Path(__file__).parent / "data" / "emd"
4143

@@ -154,6 +156,10 @@ def test_fei_emd_si(self, lazy):
154156
np.testing.assert_equal(signal[1].data, fei_si)
155157
assert isinstance(signal[1], hs.signals.Signal1D)
156158

159+
@pytest.mark.skipif(
160+
Version(hyperspy.__version__) <= Version("2.3.0"),
161+
reason="HyperSpy > 2.3.0 required.",
162+
)
157163
@pytest.mark.parametrize("lazy", (True, False))
158164
def test_fei_emd_si_non_square_10frames(self, lazy):
159165
s = hs.load(

rsciio/tests/test_hspy.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
import dask.array as da
2626
import numpy as np
2727
import pytest
28+
from packaging.version import Version
2829

2930
from rsciio.utils.tests import assert_deep_almost_equal
3031
from rsciio.utils.tools import get_file_handle
3132

3233
hs = pytest.importorskip("hyperspy.api", reason="hyperspy not installed")
3334
h5py = pytest.importorskip("h5py", reason="h5py not installed")
3435

36+
import hyperspy # noqa: E402
3537
from hyperspy.axes import ( # noqa: E402
3638
AxesManager,
3739
DataAxis,
@@ -479,6 +481,10 @@ def test_nonuniformFDA(tmp_path, file, lazy):
479481
assert s2.axes_manager[0].size == data.size
480482

481483

484+
@pytest.mark.skipif(
485+
Version(hyperspy.__version__) <= Version("2.3.0"),
486+
reason="HyperSpy > 2.3.0 required.",
487+
)
482488
def test_lazy_loading(tmp_path):
483489
s = hs.signals.BaseSignal(np.empty((5, 5, 5)))
484490
fname = tmp_path / "tmp.hdf5"
@@ -1039,6 +1045,10 @@ def test_saving_show_progressbar(tmp_path, file, show_progressbar):
10391045
s.save(filename, show_progressbar=show_progressbar)
10401046

10411047

1048+
@pytest.mark.skipif(
1049+
Version(hyperspy.__version__) <= Version("2.3.0"),
1050+
reason="HyperSpy > 2.3.0 required.",
1051+
)
10421052
def test_saving_close_file(tmp_path):
10431053
from rsciio.utils.exceptions import VisibleDeprecationWarning
10441054

rsciio/tests/test_tiff.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
hs = pytest.importorskip("hyperspy.api", reason="hyperspy not installed")
3131
t = pytest.importorskip("traits.api", reason="traits not installed")
3232

33+
import hyperspy # noqa: E402
34+
3335
import rsciio.tiff # noqa: E402
3436
from rsciio.utils.tests import assert_deep_almost_equal # noqa: E402
3537

@@ -224,6 +226,10 @@ def test_lazy_loading(tmp_path, size):
224226
fh.close()
225227

226228

229+
@pytest.mark.skipif(
230+
Version(hyperspy.__version__) <= Version("2.3.0"),
231+
reason="HyperSpy > 2.3.0 required.",
232+
)
227233
def test_lazy_loading_hyperspy_close(tmp_path):
228234
# check that the file is closed automatically in hyperspy
229235
dummy_data = np.random.random_sample(size=(2, 50, 50))

0 commit comments

Comments
 (0)