Skip to content

Commit

Permalink
Fix minimum build on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpre committed Nov 25, 2023
1 parent 4b6d01a commit defaaa2
Showing 1 changed file with 42 additions and 45 deletions.
87 changes: 42 additions & 45 deletions rsciio/tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

import pytest

import rsciio
from rsciio import IO_PLUGINS


def test_import_version():
from rsciio import __version__


def test_rsciio_dir():
import rsciio

assert dir(rsciio) == ["IO_PLUGINS", "__version__"]


Expand All @@ -39,8 +40,6 @@ def test_rsciio_utils():


def test_import_all():
from rsciio import IO_PLUGINS

plugin_name_to_remove = []

# Remove plugins which require not installed optional dependencies
Expand Down Expand Up @@ -85,20 +84,18 @@ def test_import_all():
except Exception:
plugin_name_to_remove.append("ZSPY")

IO_PLUGINS = list(
IO_PLUGINS_ = list(
filter(
lambda plugin: plugin["name"] not in set(plugin_name_to_remove),
IO_PLUGINS,
)
)

for plugin in IO_PLUGINS:
for plugin in IO_PLUGINS_:
importlib.import_module(plugin["api"])


def test_format_name_aliases():
from rsciio import IO_PLUGINS

for reader in IO_PLUGINS:
assert isinstance(reader["name"], str)
assert isinstance(reader["name_aliases"], list)
Expand All @@ -119,40 +116,40 @@ def test_format_name_aliases():
assert isinstance(reader["non_uniform_axis"], bool)


def test_dir_plugins():
from rsciio import IO_PLUGINS

for plugin in IO_PLUGINS:
plugin_string = "rsciio.%s" % plugin["name"].lower()
# skip for missing optional dependencies
if plugin["name"] == "Blockfile":
pytest.importorskip("skimage")
elif plugin["name"] == "MRCZ":
pytest.importorskip("mrcz")
elif plugin["name"] in ["TIFF", "Phenom"]:
pytest.importorskip("tifffile")
elif plugin["name"] == "USID":
pytest.importorskip("pyUSID")
elif plugin["name"] == "ZSPY":
pytest.importorskip("zarr")
elif plugin["name"] in ["EMD", "JEOL"]:
pytest.importorskip("sparse")
plugin_module = importlib.import_module(plugin_string)

if plugin["name"] == "MSA":
assert dir(plugin_module) == [
"file_reader",
"file_writer",
"parse_msa_string",
]
elif plugin["name"] == "QuantumDetector":
assert dir(plugin_module) == [
"file_reader",
"load_mib_data",
"parse_exposures",
"parse_timestamps",
]
elif plugin["writes"] is False:
assert dir(plugin_module) == ["file_reader"]
else:
assert dir(plugin_module) == ["file_reader", "file_writer"]
@pytest.mark.parametrize("plugin", IO_PLUGINS)
def test_dir_plugins(plugin):
plugin_string = "rsciio.%s" % plugin["name"].lower()
# skip for missing optional dependencies
if plugin["name"] == "Blockfile":
pytest.importorskip("skimage")
elif plugin["name"] == "Image":
pytest.importorskip("imageio")
elif plugin["name"] == "MRCZ":
pytest.importorskip("mrcz")
elif plugin["name"] in ["TIFF", "Phenom"]:
pytest.importorskip("tifffile")
elif plugin["name"] == "USID":
pytest.importorskip("pyUSID")
elif plugin["name"] == "ZSPY":
pytest.importorskip("zarr")
elif plugin["name"] in ["EMD", "HSPY", "NeXus"]:
pytest.importorskip("h5py")
plugin_module = importlib.import_module(plugin_string)

if plugin["name"] == "MSA":
assert dir(plugin_module) == [
"file_reader",
"file_writer",
"parse_msa_string",
]
elif plugin["name"] == "QuantumDetector":
assert dir(plugin_module) == [
"file_reader",
"load_mib_data",
"parse_exposures",
"parse_timestamps",
]
elif plugin["writes"] is False:
assert dir(plugin_module) == ["file_reader"]
else:
assert dir(plugin_module) == ["file_reader", "file_writer"]

0 comments on commit defaaa2

Please sign in to comment.