Skip to content

Commit

Permalink
TST: Consolidate test marks that skip if shapely is not installed (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-ward authored Jul 15, 2024
1 parent 7949dff commit 4aea090
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
14 changes: 4 additions & 10 deletions pyogrio/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
[
Expand All @@ -332,19 +330,15 @@ 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(
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",
[
Expand Down
25 changes: 7 additions & 18 deletions pyogrio/tests/test_raw_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
prepare_testfile,
requires_pyarrow_api,
requires_arrow_api,
requires_shapely,
)

try:
Expand Down Expand Up @@ -117,9 +118,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,
Expand Down Expand Up @@ -281,9 +280,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",
[
Expand All @@ -297,17 +294,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",
[
Expand Down Expand Up @@ -342,9 +335,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,
Expand All @@ -355,9 +346,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,
Expand Down

0 comments on commit 4aea090

Please sign in to comment.