From 2f326ebf26053c4a0d935531a78c45a404e90b4d Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Sun, 15 Mar 2026 10:04:52 -0600 Subject: [PATCH] TST: Update check for pykdtree/scipy in test images When running tests without scipy installed, these modules can't be collected and cause the entire run to fail. Add the skip marker to the top level before any imports. --- lib/cartopy/tests/mpl/test_images.py | 9 +++++---- lib/cartopy/tests/test_img_tiles.py | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/cartopy/tests/mpl/test_images.py b/lib/cartopy/tests/mpl/test_images.py index c698e0e59..14a99038a 100644 --- a/lib/cartopy/tests/mpl/test_images.py +++ b/lib/cartopy/tests/mpl/test_images.py @@ -13,16 +13,17 @@ import pytest import shapely.geometry as sgeom -from cartopy import config -import cartopy.crs as ccrs -import cartopy.io.img_tiles as cimgt from cartopy.tests.conftest import _HAS_PYKDTREE_OR_SCIPY -import cartopy.tests.test_img_tiles as ctest_tiles if not _HAS_PYKDTREE_OR_SCIPY: pytest.skip('pykdtree or scipy is required', allow_module_level=True) +from cartopy import config +import cartopy.crs as ccrs +import cartopy.io.img_tiles as cimgt +import cartopy.tests.test_img_tiles as ctest_tiles + NATURAL_EARTH_IMG = (config["repo_data_dir"] / 'raster' / 'natural_earth' / '50-natural-earth-1-downsampled.png') diff --git a/lib/cartopy/tests/test_img_tiles.py b/lib/cartopy/tests/test_img_tiles.py index d92224ee7..0f57e4acb 100644 --- a/lib/cartopy/tests/test_img_tiles.py +++ b/lib/cartopy/tests/test_img_tiles.py @@ -13,6 +13,12 @@ import pytest import shapely.geometry as sgeom +from cartopy.tests.conftest import _HAS_PYKDTREE_OR_SCIPY + + +if not _HAS_PYKDTREE_OR_SCIPY: + pytest.skip('pykdtree or scipy is required', allow_module_level=True) + from cartopy import config import cartopy.crs as ccrs import cartopy.io.img_tiles as cimgt