Skip to content

Commit 4aea090

Browse files
authored
TST: Consolidate test marks that skip if shapely is not installed (#439)
1 parent 7949dff commit 4aea090

File tree

2 files changed

+11
-28
lines changed

2 files changed

+11
-28
lines changed

pyogrio/tests/test_core.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pyogrio.core import detect_write_driver
1717
from pyogrio._compat import GDAL_GE_38
1818
from pyogrio.errors import DataSourceError, DataLayerError
19-
from pyogrio.tests.conftest import HAS_SHAPELY, prepare_testfile
19+
from pyogrio.tests.conftest import prepare_testfile, requires_shapely
2020

2121
from pyogrio._env import GDALEnv
2222

@@ -316,9 +316,7 @@ def test_read_bounds_bbox(naturalearth_lowres_all_ext):
316316
)
317317

318318

319-
@pytest.mark.skipif(
320-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
321-
)
319+
@requires_shapely
322320
@pytest.mark.parametrize(
323321
"mask",
324322
[
@@ -332,19 +330,15 @@ def test_read_bounds_mask_invalid(naturalearth_lowres, mask):
332330
read_bounds(naturalearth_lowres, mask=mask)
333331

334332

335-
@pytest.mark.skipif(
336-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
337-
)
333+
@requires_shapely
338334
def test_read_bounds_bbox_mask_invalid(naturalearth_lowres):
339335
with pytest.raises(ValueError, match="cannot set both 'bbox' and 'mask'"):
340336
read_bounds(
341337
naturalearth_lowres, bbox=(-85, 8, -80, 10), mask=shapely.Point(-105, 55)
342338
)
343339

344340

345-
@pytest.mark.skipif(
346-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
347-
)
341+
@requires_shapely
348342
@pytest.mark.parametrize(
349343
"mask,expected",
350344
[

pyogrio/tests/test_raw_io.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
prepare_testfile,
2828
requires_pyarrow_api,
2929
requires_arrow_api,
30+
requires_shapely,
3031
)
3132

3233
try:
@@ -117,9 +118,7 @@ def test_read_no_geometry(naturalearth_lowres):
117118
assert geometry is None
118119

119120

120-
@pytest.mark.skipif(
121-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
122-
)
121+
@requires_shapely
123122
def test_read_no_geometry__mask(naturalearth_lowres):
124123
geometry, fields = read(
125124
naturalearth_lowres,
@@ -281,9 +280,7 @@ def test_read_bbox_where(naturalearth_lowres_all_ext):
281280
assert np.array_equal(fields[3], ["CAN"])
282281

283282

284-
@pytest.mark.skipif(
285-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
286-
)
283+
@requires_shapely
287284
@pytest.mark.parametrize(
288285
"mask",
289286
[
@@ -297,17 +294,13 @@ def test_read_mask_invalid(naturalearth_lowres, mask):
297294
read(naturalearth_lowres, mask=mask)
298295

299296

300-
@pytest.mark.skipif(
301-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
302-
)
297+
@requires_shapely
303298
def test_read_bbox_mask_invalid(naturalearth_lowres):
304299
with pytest.raises(ValueError, match="cannot set both 'bbox' and 'mask'"):
305300
read(naturalearth_lowres, bbox=(-85, 8, -80, 10), mask=shapely.Point(-105, 55))
306301

307302

308-
@pytest.mark.skipif(
309-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
310-
)
303+
@requires_shapely
311304
@pytest.mark.parametrize(
312305
"mask,expected",
313306
[
@@ -342,9 +335,7 @@ def test_read_mask(naturalearth_lowres_all_ext, mask, expected):
342335
assert len(geometry) == len(expected)
343336

344337

345-
@pytest.mark.skipif(
346-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
347-
)
338+
@requires_shapely
348339
def test_read_mask_sql(naturalearth_lowres_all_ext):
349340
fields = read(
350341
naturalearth_lowres_all_ext,
@@ -355,9 +346,7 @@ def test_read_mask_sql(naturalearth_lowres_all_ext):
355346
assert np.array_equal(fields[3], ["CAN"])
356347

357348

358-
@pytest.mark.skipif(
359-
not HAS_SHAPELY, reason="Shapely is required for mask functionality"
360-
)
349+
@requires_shapely
361350
def test_read_mask_where(naturalearth_lowres_all_ext):
362351
fields = read(
363352
naturalearth_lowres_all_ext,

0 commit comments

Comments
 (0)