From 614159bd3ef0c7f773008696f6edebe6e8e71f71 Mon Sep 17 00:00:00 2001 From: Robbi Bishop-Taylor Date: Wed, 9 Oct 2024 07:10:51 +0000 Subject: [PATCH] Only load test data once --- Makefile | 4 ++-- tests/conftest.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e72c1d7..bfc66e4 100644 --- a/Makefile +++ b/Makefile @@ -33,14 +33,14 @@ test-model: ## Test model module with pytest @echo "🚀 Testing model module: Running pytest" @tar --skip-old-files -xzf ./tests/data/tide_models.tar.gz -C ./tests/data @export EO_TIDES_TIDE_MODELS=./tests/data/tide_models && \ - uv run python -m pytest tests/test_model.py + uv run python -m pytest tests/test_model.py --verbose .PHONY: test-eo test-eo: ## Test eo module with pytest @echo "🚀 Testing eo module: Running pytest" @tar --skip-old-files -xzf ./tests/data/tide_models.tar.gz -C ./tests/data @export EO_TIDES_TIDE_MODELS=./tests/data/tide_models && \ - uv run python -m pytest tests/test_eo.py + uv run python -m pytest tests/test_eo.py --verbose .PHONY: test-notebooks test-notebooks: ## Test notebooks with pytest diff --git a/tests/conftest.py b/tests/conftest.py index 48c5ff3..5bbc1ec 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,8 @@ This module contains shared fixtures for eo_tides tests. """ +from copy import deepcopy + import odc.stac import pandas as pd import pystac_client @@ -47,8 +49,9 @@ def measured_tides_ds(): ("EPSG:4326", 0.00025), # WGS84, 0.0025 degree pixels ], ids=["satellite_ds_epsg3577", "satellite_ds_epsg4326"], + scope="session", # only load data once, but copy for each test ) -def satellite_ds(request): +def satellite_ds_load(request): """ Load a sample timeseries of Landsat 8 data using odc-stac """ @@ -85,3 +88,12 @@ def satellite_ds(request): ) return ds + + +@pytest.fixture +def satellite_ds(satellite_ds_load): + """ + Make a copy of the previously loaded satellite data for + each test to ensure each test is independent + """ + return deepcopy(satellite_ds_load)