diff --git a/CHANGELOG.md b/CHANGELOG.md index b45f4fbf..3c3c63fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ Keep it human-readable, your future self will thank you! ## [Unreleased](https://github.com/ecmwf/anemoi-datasets/compare/0.5.8...HEAD) +### Changed +- make test optional when adls is not installed Pull request #110 + ## [0.5.8](https://github.com/ecmwf/anemoi-datasets/compare/0.5.7...0.5.8) - 2024-10-26 ### Changed diff --git a/tests/create/test_create.py b/tests/create/test_create.py index b330bbfd..6e3f381b 100755 --- a/tests/create/test_create.py +++ b/tests/create/test_create.py @@ -11,6 +11,7 @@ import hashlib import json import os +import sys from functools import wraps from unittest.mock import patch @@ -37,6 +38,24 @@ assert NAMES, "No yaml files found in " + HERE +def is_ubuntu(): + if os.path.isfile("/etc/os-release"): + with open("/etc/os-release") as f: + return "Ubuntu" in f.read() + return False + + +def is_darwin(): + if os.path.isfile("/etc/os-release"): + with open("/etc/os-release") as f: + return "Darwin" in f.read() + return False + + +# run extensive tests only on Ubuntu and Darwin, and not on Python 3.9 and 3.11 +extensive_tests = (sys.version_info[:2] not in [(3, 9), (3, 11)]) and (is_ubuntu() or is_darwin()) + + def mockup_from_source(func): @wraps(func) def wrapper(*args, **kwargs): @@ -233,6 +252,7 @@ def compare(self): @pytest.mark.parametrize("name", NAMES) +@pytest.mark.skipif(not extensive_tests, reason="Skipping to run the test faster") @mockup_from_source def test_run(name): config = os.path.join(HERE, name + ".yaml") diff --git a/tests/xarray/test_zarr.py b/tests/xarray/test_zarr.py index 4660f366..5847063c 100644 --- a/tests/xarray/test_zarr.py +++ b/tests/xarray/test_zarr.py @@ -8,12 +8,20 @@ # nor does it submit to any jurisdiction. +import pytest import xarray as xr from anemoi.datasets.create.functions.sources.xarray import XarrayFieldList from anemoi.datasets.data.stores import name_to_zarr_store from anemoi.datasets.testing import assert_field_list +try: + import adlfs # noqa: F401 + + HAS_ADLS = True +except ImportError: + HAS_ADLS = False + def test_arco_era5_1(): @@ -118,6 +126,7 @@ def test_noaa_replay(): ) +@pytest.mark.skipif(not HAS_ADLS, reason="package adlfs not installed") def test_planetary_computer_conus404(): url = "https://planetarycomputer.microsoft.com/api/stac/v1/collections/conus404" ds = xr.open_zarr(**name_to_zarr_store(url))