Skip to content

Commit

Permalink
Adjust test expectations in light of 3.9.0 (#3091)
Browse files Browse the repository at this point in the history
* Adjust test expectations in light of 3.9.0

* Appease flake8

* xfail new shape mask test

See #3074
  • Loading branch information
sgillies committed May 10, 2024
1 parent 7ea50ed commit 24d0845
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
12 changes: 12 additions & 0 deletions tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,18 @@ def test_sieve_blank_mask(basic_image):
)


@pytest.mark.xfail(reason="Upstream bug in GDAL, see #3074.")
def test_sieve_all_masked(basic_image):
"""A blank mask should have no effect."""
mask = np.full(basic_image.shape, False)
# mask[-1, -1] = True
sieved = sieve(basic_image, basic_image.sum(), mask=mask)
assert np.array_equal(
basic_image,
sieved
)


def test_sieve_invalid_mask_shape(basic_image):
"""A mask that is the wrong shape should fail."""
with pytest.raises(ValueError):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_mask_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from rasterio.errors import RasterioIOError
from rasterio.windows import Window

from .conftest import gdal_version


def test_create_internal_mask(data):
"""Write an internal mask to the fixture's RGB.byte.tif."""
Expand All @@ -32,6 +34,7 @@ def test_create_internal_mask(data):
assert MaskFlags.nodata not in flags


@pytest.mark.xfail(gdal_version.at_least("3.9"), reason="Internal mask are the default since 3.9.0.")
def test_create_sidecar_mask(data):
"""Write a .msk sidecar mask."""
with rasterio.open(str(data.join('RGB.byte.tif')), 'r+') as dst:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def test_chained_io_errors(path_rgb_byte_tif):
exc = excinfo.value.__cause__
assert isinstance(exc, CPLE_AppDefinedError)
msg = str(exc)
assert msg.startswith("tests/data/corrupt.tif")
assert "corrupt.tif" in msg
assert "IReadBlock failed" in msg

# Exception ~2 is another AppDefinedError mentioning TIFFReadEncodedTile.
Expand Down
6 changes: 1 addition & 5 deletions tests/test_update.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import subprocess
import re
"""Tests of updating a dataset's tags etc."""

import affine
import numpy as np
Expand All @@ -8,7 +7,6 @@
import rasterio


@pytest.mark.gdalbin
def test_update_tags(data):
tiffname = str(data.join('RGB.byte.tif'))
with rasterio.open(tiffname, 'r+') as f:
Expand All @@ -18,8 +16,6 @@ def test_update_tags(data):
f.update_tags(4, d=4)
assert f.tags() == {'AREA_OR_POINT': 'Area', 'a': '1', 'b': '2'}
assert ('c', '3') in f.tags(1).items()
info = subprocess.check_output(["gdalinfo", tiffname]).decode('utf-8')
assert re.search(r'Metadata:\W+a=1\W+AREA_OR_POINT=Area\W+b=2', info)


def test_update_band(data):
Expand Down

0 comments on commit 24d0845

Please sign in to comment.