Add a failing test related to gh-2382

And change xfails for GDAL versions > 3.3.
This commit is contained in:
Sean Gillies 2022-04-12 14:55:14 -06:00
parent 1dc4b415eb
commit 8a0a3611b0
3 changed files with 34 additions and 7 deletions

View File

@ -36,6 +36,7 @@ def mock_debian(tmpdir):
tmpdir.ensure("share/gdal/3.2/header.dxf")
tmpdir.ensure("share/gdal/3.3/header.dxf")
tmpdir.ensure("share/gdal/3.4/header.dxf")
tmpdir.ensure("share/gdal/3.5/header.dxf")
tmpdir.ensure("share/proj/epsg")
return tmpdir

View File

@ -28,8 +28,36 @@ def test_outer_boundless_pixel_fidelity(
assert rgb_padded.shape == (dataset.count, height, width)
rgb = dataset.read()
assert numpy.all(
rgb == rgb_padded[:, -row_start:height - row_stop,
-col_start:width - col_stop])
rgb
== rgb_padded[
:, -row_start : height - row_stop, -col_start : width - col_stop
]
)
@pytest.mark.xfail(reason="The bug reported in gh-2382")
@requires_gdal21(reason="Pixel equality tests require float windows and GDAL 2.1")
@given(
col_start=st.integers(min_value=-700, max_value=0),
row_start=st.integers(min_value=-700, max_value=0),
col_stop=st.integers(min_value=0, max_value=700),
row_stop=st.integers(min_value=0, max_value=700),
)
def test_outer_upper_left_boundless_pixel_fidelity(
path_rgb_byte_tif, col_start, row_start, col_stop, row_stop
):
"""An outer boundless read doesn't change pixels"""
with rasterio.open(path_rgb_byte_tif) as dataset:
width = dataset.width - col_stop - col_start
height = dataset.height - row_stop - row_start
window = Window(col_start, row_start, width, height)
rgb_boundless = dataset.read(window=window, boundless=True)
assert rgb_boundless.shape == (dataset.count, height, width)
rgb = dataset.read()
assert numpy.all(
rgb[:, 0 : height + row_start, 0 : width + col_start]
== rgb_boundless[:, -row_start:height, -col_start:width]
)
def test_image(red_green):
@ -121,10 +149,6 @@ def test_boundless_masked_fill_value_overview_masks():
assert data.mask[:, 0].all()
@pytest.mark.xfail(
gdal_version.major == 1,
reason="GDAL versions < 2 do not support OVERVIEW_LEVEL open option",
)
def test_boundless_open_options():
"""Open options are taken into account"""
with rasterio.open("tests/data/cogeo.tif", overview_level=1) as src:

View File

@ -35,7 +35,8 @@ def test_cplerror_str():
assert str(err) == "test123"
@pytest.mark.xfail(gdal_version < GDALVersion(3, 3), reason="GDAL <3.3 will not warn")
@pytest.mark.xfail(gdal_version < GDALVersion(3, 3), reason="GDAL < 3.3 will not warn")
@pytest.mark.xfail(gdal_version > GDALVersion(3, 3), reason="GDAL > 3.3 will not warn")
def test_issue2353(caplog, path_rgb_byte_tif):
"""Ensure transformer doesn't leave errors behind."""
from rasterio.warp import calculate_default_transform
@ -58,6 +59,7 @@ def test_issue2353(caplog, path_rgb_byte_tif):
@pytest.mark.xfail(gdal_version < GDALVersion(3, 3), reason="GDAL <3.3 will not warn")
@pytest.mark.xfail(gdal_version > GDALVersion(3, 3), reason="GDAL > 3.3 will not warn")
def test_issue2353bis(caplog, path_rgb_byte_tif):
"""Ensure VRT doesn't leave errors behind."""
from rasterio.vrt import WarpedVRT