diff --git a/pyogrio/tests/test_core.py b/pyogrio/tests/test_core.py index ed0a5ef9..ef73ea41 100644 --- a/pyogrio/tests/test_core.py +++ b/pyogrio/tests/test_core.py @@ -16,7 +16,7 @@ from pyogrio.core import detect_write_driver from pyogrio._compat import GDAL_GE_38 from pyogrio.errors import DataSourceError, DataLayerError -from pyogrio.tests.conftest import HAS_SHAPELY, prepare_testfile +from pyogrio.tests.conftest import prepare_testfile, requires_shapely from pyogrio._env import GDALEnv @@ -316,9 +316,7 @@ def test_read_bounds_bbox(naturalearth_lowres_all_ext): ) -@pytest.mark.skipif( - not HAS_SHAPELY, reason="Shapely is required for mask functionality" -) +@requires_shapely @pytest.mark.parametrize( "mask", [ @@ -332,9 +330,7 @@ def test_read_bounds_mask_invalid(naturalearth_lowres, mask): read_bounds(naturalearth_lowres, mask=mask) -@pytest.mark.skipif( - not HAS_SHAPELY, reason="Shapely is required for mask functionality" -) +@requires_shapely def test_read_bounds_bbox_mask_invalid(naturalearth_lowres): with pytest.raises(ValueError, match="cannot set both 'bbox' and 'mask'"): read_bounds( @@ -342,9 +338,7 @@ def test_read_bounds_bbox_mask_invalid(naturalearth_lowres): ) -@pytest.mark.skipif( - not HAS_SHAPELY, reason="Shapely is required for mask functionality" -) +@requires_shapely @pytest.mark.parametrize( "mask,expected", [ diff --git a/pyogrio/tests/test_raw_io.py b/pyogrio/tests/test_raw_io.py index f45d1f85..9026934c 100644 --- a/pyogrio/tests/test_raw_io.py +++ b/pyogrio/tests/test_raw_io.py @@ -26,6 +26,7 @@ prepare_testfile, requires_pyarrow_api, requires_arrow_api, + requires_shapely, ) try: @@ -116,9 +117,7 @@ def test_read_no_geometry(naturalearth_lowres): assert geometry is None -@pytest.mark.skipif( - not HAS_SHAPELY, reason="Shapely is required for mask functionality" -) +@requires_shapely def test_read_no_geometry__mask(naturalearth_lowres): geometry, fields = read( naturalearth_lowres, @@ -280,9 +279,7 @@ def test_read_bbox_where(naturalearth_lowres_all_ext): assert np.array_equal(fields[3], ["CAN"]) -@pytest.mark.skipif( - not HAS_SHAPELY, reason="Shapely is required for mask functionality" -) +@requires_shapely @pytest.mark.parametrize( "mask", [ @@ -296,17 +293,13 @@ def test_read_mask_invalid(naturalearth_lowres, mask): read(naturalearth_lowres, mask=mask) -@pytest.mark.skipif( - not HAS_SHAPELY, reason="Shapely is required for mask functionality" -) +@requires_shapely def test_read_bbox_mask_invalid(naturalearth_lowres): with pytest.raises(ValueError, match="cannot set both 'bbox' and 'mask'"): read(naturalearth_lowres, bbox=(-85, 8, -80, 10), mask=shapely.Point(-105, 55)) -@pytest.mark.skipif( - not HAS_SHAPELY, reason="Shapely is required for mask functionality" -) +@requires_shapely @pytest.mark.parametrize( "mask,expected", [ @@ -341,9 +334,7 @@ def test_read_mask(naturalearth_lowres_all_ext, mask, expected): assert len(geometry) == len(expected) -@pytest.mark.skipif( - not HAS_SHAPELY, reason="Shapely is required for mask functionality" -) +@requires_shapely def test_read_mask_sql(naturalearth_lowres_all_ext): fields = read( naturalearth_lowres_all_ext, @@ -354,9 +345,7 @@ def test_read_mask_sql(naturalearth_lowres_all_ext): assert np.array_equal(fields[3], ["CAN"]) -@pytest.mark.skipif( - not HAS_SHAPELY, reason="Shapely is required for mask functionality" -) +@requires_shapely def test_read_mask_where(naturalearth_lowres_all_ext): fields = read( naturalearth_lowres_all_ext,