From 25d0092918434208c831eb65b21f383cfdbb44a2 Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Mon, 2 Dec 2024 23:33:32 +0100 Subject: [PATCH] Skip tests with missing requirements --- examples/read-csv/main.py | 7 ------- examples/read-csv/readcsv.py | 5 +++++ storages/python/tests-python/test_image.py | 8 ++++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/read-csv/main.py b/examples/read-csv/main.py index c7961a81f..cbebd35a9 100644 --- a/examples/read-csv/main.py +++ b/examples/read-csv/main.py @@ -1,8 +1 @@ -try: - import pandas # noqa: F401 - import tables # noqa: F401 -except ImportError: - import sys - sys.exit(44) # skip this test if pandas is not available - import readcsv # noqa: F401 diff --git a/examples/read-csv/readcsv.py b/examples/read-csv/readcsv.py index 8b1a9e545..687aa74ea 100644 --- a/examples/read-csv/readcsv.py +++ b/examples/read-csv/readcsv.py @@ -1,6 +1,11 @@ from pathlib import Path import dlite +from dlite import importskip + +importskip("pandas") +importskip("tables") +importskip("yaml") # Set up some paths diff --git a/storages/python/tests-python/test_image.py b/storages/python/tests-python/test_image.py index a27bf7922..0092c7fbb 100644 --- a/storages/python/tests-python/test_image.py +++ b/storages/python/tests-python/test_image.py @@ -2,12 +2,12 @@ from pathlib import Path import numpy as np + import dlite +from dlite.testutils import importskip -try: - import skimage -except ImportError: - sys.exit(44) # skip test +importskip("scipy") +importskip("skimage") thisdir = Path(__file__).absolute().parent