xfail some pixel value senstivie tests when gdal < 2

This commit is contained in:
Sean Gillies 2017-06-11 17:14:29 +02:00
parent b8b5df23b9
commit d7ea5bfbfe
6 changed files with 38 additions and 13 deletions

View File

@ -234,7 +234,7 @@ cdef class DatasetReaderBase(DatasetBase):
self.height, self.width)
int_window = windows.int_reshape(window)
win_shape += (int_window.num_rows, int_window.num_cols)
win_shape += (int(int_window.num_rows), int(int_window.num_cols))
else:
win_shape += self.shape
@ -472,7 +472,7 @@ cdef class DatasetReaderBase(DatasetBase):
self.height, self.width)
int_window = windows.int_reshape(window)
win_shape += (int_window.num_rows, int_window.num_cols)
win_shape += (int(int_window.num_rows), int(int_window.num_cols))
else:
win_shape += self.shape

View File

@ -26,7 +26,7 @@ def warn_window_deprecation():
"""Standard warning about range tuple deprecation"""
warnings.warn(
"Range tuple window are deprecated. Please switch to Window class",
DeprecationWarning, stacklevel=2)
DeprecationWarning)
def iter_args(function):

View File

@ -1,12 +1,18 @@
"""Unittests for rasterio.mask"""
from packaging.version import parse
import pytest
import rasterio
from rasterio.mask import mask as mask_tool
# Custom markers.
xfail_pixel_sensitive_gdal2 = pytest.mark.xfail(
parse(rasterio.__gdal_version__) < parse('2.0dev'),
reason="This test is sensitive to pixel values and requires GDAL 2.0+")
def test_nodata(basic_image_file, basic_geometry):
nodata_val = 0
geometries = [basic_geometry]
@ -24,6 +30,7 @@ def test_no_nodata(basic_image_file, basic_geometry):
assert(masked.data.all() == default_nodata_val)
@xfail_pixel_sensitive_gdal2
def test_crop(basic_image, basic_image_file, basic_geometry):
geometries = [basic_geometry]
with rasterio.open(basic_image_file, "r") as src:
@ -37,6 +44,7 @@ def test_crop(basic_image, basic_image_file, basic_geometry):
assert (masked[0] == image[2:5, 2:5]).all()
@xfail_pixel_sensitive_gdal2
def test_crop_all_touched(basic_image, basic_image_file, basic_geometry):
geometries = [basic_geometry]
with rasterio.open(basic_image_file, "r") as src:

View File

@ -7,6 +7,7 @@ import warnings
from affine import Affine
import numpy as np
from packaging.version import parse
import pytest
import rasterio
@ -19,6 +20,12 @@ DEFAULT_SHAPE = (10, 10)
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
# Custom markers.
xfail_without_gdal2 = pytest.mark.xfail(
parse(rasterio.__gdal_version__) < parse('2.0dev'),
reason="This test is sensitive to pixel values and requires GDAL 2.0+")
def bbox(*args):
return ' '.join([str(x) for x in args])
@ -169,6 +176,7 @@ def test_mask_invalid_geojson(runner, tmpdir, pixelated_image_file):
assert 'Invalid GeoJSON' in result.output
@xfail_without_gdal2
def test_mask_crop(runner, tmpdir, basic_feature, pixelated_image):
"""
In order to test --crop option, we need to use a transform more similar to
@ -206,6 +214,7 @@ def test_mask_crop(runner, tmpdir, basic_feature, pixelated_image):
out.read(1, masked=True).filled(0))
@xfail_without_gdal2
def test_mask_crop_inverted_y(runner, tmpdir, basic_feature, pixelated_image_file):
"""
--crop option should also work if raster has a positive y pixel size

View File

@ -4,7 +4,7 @@ import sys
import click
from click.testing import CliRunner
from packaging.version import Version
from packaging.version import Version, parse
import pytest
import rasterio
@ -13,9 +13,6 @@ from rasterio.rio.edit_info import (
from rasterio.rio.main import main_group
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
def test_delete_nodata_exclusive_opts(data):
"""--unset-nodata and --nodata can't be used together"""
runner = CliRunner()
@ -34,8 +31,8 @@ def test_delete_crs_exclusive_opts(data):
assert result.exit_code == 2
@pytest.mark.xfail(
Version(rasterio.__gdal_version__) < Version('1.10'),
@pytest.mark.skip(
parse(rasterio.__gdal_version__) < parse('1.10'),
reason='GDAL version >= 1.10 required')
def test_unset_crs(data):
runner = CliRunner()
@ -48,7 +45,7 @@ def test_unset_crs(data):
@pytest.mark.skip(
Version(rasterio.__gdal_version__) >= Version('1.10'),
parse(rasterio.__gdal_version__) >= parse('1.10'),
reason='Test applies to GDAL version < 1.10')
def test_unset_crs_gdal19(data):
"""unsetting crs doesn't work for geotiff and gdal 1.9

View File

@ -8,6 +8,7 @@ import logging
import affine
from click.testing import CliRunner
import numpy as np
from packaging.version import parse
from pytest import fixture
import pytest
@ -17,7 +18,10 @@ from rasterio.rio.main import main_group
from rasterio.transform import Affine
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
# Custom markers.
xfail_pixel_sensitive_gdal2 = pytest.mark.xfail(
parse(rasterio.__gdal_version__) < parse('2.0dev'),
reason="This test is sensitive to pixel values and requires GDAL 2.0+")
# Fixture to create test datasets within temporary directory
@ -95,6 +99,7 @@ def test_merge_with_colormap(test_data_dir_1):
assert cmap[255] == (0, 0, 0, 255)
@xfail_pixel_sensitive_gdal2
def test_merge_with_nodata(test_data_dir_1):
outputname = str(test_data_dir_1.join('merged.tif'))
inputs = [str(x) for x in test_data_dir_1.listdir()]
@ -125,6 +130,7 @@ def test_merge_warn(test_data_dir_1):
assert os.path.exists(outputname)
@xfail_pixel_sensitive_gdal2
def test_merge_without_nodata(test_data_dir_2):
outputname = str(test_data_dir_2.join('merged.tif'))
inputs = [str(x) for x in test_data_dir_2.listdir()]
@ -268,6 +274,10 @@ def test_data_dir_float(tmpdir):
return tmpdir
@xfail_pixel_sensitive_gdal2
@pytest.mark.xfail(
os.environ.get('GDALVERSION', 'a.b.c').startswith('1.9'),
reason="GDAL 1.9 doesn't catch this error")
def test_merge_float(test_data_dir_float):
outputname = str(test_data_dir_float.join('merged.tif'))
inputs = [str(x) for x in test_data_dir_float.listdir()]
@ -371,6 +381,7 @@ def test_merge_tiny_output_opt(tiffs):
assert data[0][3][0] == 40
@xfail_pixel_sensitive_gdal2
def test_merge_tiny_res_bounds(tiffs):
outputname = str(tiffs.join('merged.tif'))
inputs = [str(x) for x in tiffs.listdir()]