Skip to content

TST: Consolidate test marks that skip if shapely is not installed #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -26,6 +26,7 @@
prepare_testfile,
requires_pyarrow_api,
requires_arrow_api,
requires_shapely,
)

try:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
[
Expand All @@ -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",
[
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down