From 565843e4af5bc5e4b114ffae5a2ca0b06d9d54b4 Mon Sep 17 00:00:00 2001 From: Joseph Hughes Date: Fri, 7 Aug 2026 10:31:29 -0500 Subject: [PATCH] fix(autotest): skip export tests that need geopandas The nightly optional dependency job installs the optional dependencies and then removes three of them chosen by the date, so it reaches combinations the job that installs none of them does not. Shapefile export goes through geopandas, but the export tests were marked as needing only pyshp and failed with an ImportError rather than being skipped on the night geopandas was removed. The two export tests that do not go through geopandas keep their existing mark. The mark for sklearn on test_save_load_node_mapping_structured was added commented out and never took effect, so that test failed the same way when scikit-learn was removed. --- autotest/test_export.py | 16 ++++++++-------- autotest/test_model_splitter.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/autotest/test_export.py b/autotest/test_export.py index 1bd9a9514..1640940f0 100644 --- a/autotest/test_export.py +++ b/autotest/test_export.py @@ -160,7 +160,7 @@ def unstructured_grid(example_data_path): ) -@requires_pkg("pyshp", name_map={"pyshp": "shapefile"}) +@requires_pkg("pyshp", "geopandas", name_map={"pyshp": "shapefile"}) @pytest.mark.parametrize("pathlike", (True, False)) def test_output_helper_shapefile_export(pathlike, function_tmpdir, example_data_path): ml = Modflow.load( @@ -179,7 +179,7 @@ def test_output_helper_shapefile_export(pathlike, function_tmpdir, example_data_ ) -@requires_pkg("pyshp", name_map={"pyshp": "shapefile"}) +@requires_pkg("pyshp", "geopandas", name_map={"pyshp": "shapefile"}) @pytest.mark.slow def test_freyberg_export(function_tmpdir, example_data_path): # steady state @@ -323,7 +323,7 @@ def test_write_gridlines_shapefile(function_tmpdir): assert len(sf) == 22 -@requires_pkg("pyshp", name_map={"pyshp": "shapefile"}) +@requires_pkg("pyshp", "geopandas", name_map={"pyshp": "shapefile"}) def test_export_shapefile_polygon_closed(function_tmpdir): from shapefile import Reader @@ -442,7 +442,7 @@ def test_netcdf_classmethods(function_tmpdir, example_data_path): new_f.nc.close() -@requires_pkg("pyshp", name_map={"pyshp": "shapefile"}) +@requires_pkg("pyshp", "geopandas", name_map={"pyshp": "shapefile"}) def test_shapefile_ibound(function_tmpdir, example_data_path): from shapefile import Reader @@ -465,7 +465,7 @@ def test_shapefile_ibound(function_tmpdir, example_data_path): shape.close() -@requires_pkg("pyshp", name_map={"pyshp": "shapefile"}) +@requires_pkg("pyshp", "geopandas", name_map={"pyshp": "shapefile"}) @pytest.mark.slow @pytest.mark.parametrize("namfile", namfiles()) def test_shapefile(function_tmpdir, namfile): @@ -555,7 +555,7 @@ def test_export_netcdf(function_tmpdir, namfile): nc.close() -@requires_pkg("pyshp", name_map={"pyshp": "shapefile"}) +@requires_pkg("pyshp", "geopandas", name_map={"pyshp": "shapefile"}) def test_export_array2(function_tmpdir): nrow = 7 ncol = 11 @@ -586,7 +586,7 @@ def test_export_array2(function_tmpdir): @pytest.mark.mf6 -@requires_pkg("pyshp", name_map={"pyshp": "shapefile"}) +@requires_pkg("pyshp", "geopandas", name_map={"pyshp": "shapefile"}) def test_array3d_export_structured(function_tmpdir): from shapefile import Reader @@ -2127,7 +2127,7 @@ def test_to_shapefile_raises_attributeerror(): @pytest.mark.mf6 -@requires_pkg("pyshp", name_map={"pyshp": "shapefile"}) +@requires_pkg("pyshp", "geopandas", name_map={"pyshp": "shapefile"}) @pytest.mark.parametrize("use_pandas", [True]) # TODO: test non-pandas @pytest.mark.parametrize("sparse", [True, False]) def test_mf6_chd_shapefile_export_structured(function_tmpdir, use_pandas, sparse): diff --git a/autotest/test_model_splitter.py b/autotest/test_model_splitter.py index c341da058..0f0d46515 100644 --- a/autotest/test_model_splitter.py +++ b/autotest/test_model_splitter.py @@ -221,7 +221,7 @@ def test_metis_splitting_with_lak_sfr(function_tmpdir): @requires_exe("mf6") @requires_pkg("pymetis") @requires_pkg("h5py") -# @requires_pkg("sklearn") +@requires_pkg("sklearn") def test_save_load_node_mapping_structured(function_tmpdir): import pymetis