Skip to content

Commit bf76675

Browse files
TST: update tests for changed GDAL error for GPKG sql query (#541)
1 parent 77a1a6a commit bf76675

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

pyogrio/tests/test_core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,12 @@ def test_read_bounds_negative_skip_features(naturalearth_lowres):
286286

287287

288288
def test_read_bounds_where_invalid(naturalearth_lowres_all_ext):
289-
with pytest.raises(ValueError, match="Invalid SQL"):
290-
read_bounds(naturalearth_lowres_all_ext, where="invalid")
289+
if naturalearth_lowres_all_ext.suffix == ".gpkg" and __gdal_version__ >= (3, 11, 0):
290+
with pytest.raises(DataLayerError, match="no such column"):
291+
read_bounds(naturalearth_lowres_all_ext, where="invalid")
292+
else:
293+
with pytest.raises(ValueError, match="Invalid SQL"):
294+
read_bounds(naturalearth_lowres_all_ext, where="invalid")
291295

292296

293297
def test_read_bounds_where(naturalearth_lowres):

pyogrio/tests/test_geopandas_io.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,17 @@ def test_read_where_invalid(request, naturalearth_lowres_all_ext, use_arrow):
493493
if use_arrow and naturalearth_lowres_all_ext.suffix == ".gpkg":
494494
# https://github.com/OSGeo/gdal/issues/8492
495495
request.node.add_marker(pytest.mark.xfail(reason="GDAL doesn't error for GPGK"))
496-
with pytest.raises(ValueError, match="Invalid SQL"):
497-
read_dataframe(
498-
naturalearth_lowres_all_ext, use_arrow=use_arrow, where="invalid"
499-
)
496+
497+
if naturalearth_lowres_all_ext.suffix == ".gpkg" and __gdal_version__ >= (3, 11, 0):
498+
with pytest.raises(DataLayerError, match="no such column"):
499+
read_dataframe(
500+
naturalearth_lowres_all_ext, use_arrow=use_arrow, where="invalid"
501+
)
502+
else:
503+
with pytest.raises(ValueError, match="Invalid SQL"):
504+
read_dataframe(
505+
naturalearth_lowres_all_ext, use_arrow=use_arrow, where="invalid"
506+
)
500507

501508

502509
def test_read_where_ignored_field(naturalearth_lowres, use_arrow):

0 commit comments

Comments
 (0)