From 7f0db4abfd7f263e4d49d24eea6fd9a92f9c4b91 Mon Sep 17 00:00:00 2001 From: Kevin Wurster Date: Mon, 20 Jun 2016 00:21:57 -0400 Subject: [PATCH] Remove unnecessary test, and improve some other tests. --- tests/test_deprecated.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py index 89c83ccd..938bdf7e 100644 --- a/tests/test_deprecated.py +++ b/tests/test_deprecated.py @@ -1,25 +1,38 @@ """Unittests for deprecated features""" +import warnings + import affine import pytest import rasterio -from rasterio.transform import guard_transform def test_open_affine_and_transform(path_rgb_byte_tif): - with pytest.raises(ValueError) as e: + """Passsing both 'affine' and 'transform' to rasterio.open() should issue + some helpful warnings. + + By settings the 'affine' kwarg to a wacky value we ensure that the + 'transform' kwarg is used while ignoring the 'affine' kwarg. + """ + with warnings.catch_warnings(record=True) as w: with rasterio.open( path_rgb_byte_tif, - affine=affine.Affine.identity(), + affine=rasterio, transform=affine.Affine.identity()) as src: pass - for word in 'affine', 'transform', 'exclusive': - assert word in str(e) + assert len(w) == 2 + assert "'affine' kwarg in rasterio.open() is deprecated" \ + in str(w[0].message) + assert "Found both 'affine' and 'transform'" in str(w[1].message) + assert "choosing 'transform'" in str(w[1].message) -def test_open_transform_not_Affine(path_rgb_byte_tif): +def test_open_transform_gdal_geotransform(path_rgb_byte_tif): + """Passing a GDAL geotransform to rasterio.open(transform=...) should raise + an exception. + """ with pytest.raises(TypeError): with rasterio.open( path_rgb_byte_tif, @@ -36,16 +49,8 @@ def test_open_affine_kwarg_warning(path_rgb_byte_tif): pass -def test_guard_transform_gdal_exception(path_rgb_byte_tif): - """A GDAL-style transform passed to `guard_transform()` should fail.""" - with rasterio.open(path_rgb_byte_tif) as src: - transform = src.transform - with pytest.raises(ValueError): - guard_transform(transform.to_gdal()) - - def test_src_affine_warning(path_rgb_byte_tif): """Calling src.affine should raise a warning.""" with pytest.warns(DeprecationWarning): with rasterio.open(path_rgb_byte_tif) as src: - src.affine + assert src.affine == src.transform