From 2f11fc93412f5c9af3a0729ffd650b38ba26f993 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Fri, 15 Dec 2023 10:11:35 -0600 Subject: [PATCH] Check for expected fill value warning --- trollimage/tests/test_image.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/trollimage/tests/test_image.py b/trollimage/tests/test_image.py index fe364dc0..0a109080 100644 --- a/trollimage/tests/test_image.py +++ b/trollimage/tests/test_image.py @@ -935,7 +935,8 @@ def test_save_geotiff_float(self): # with fill value with NamedTemporaryFile(suffix='.tif') as tmp: - img.save(tmp.name, fill_value=128) + with pytest.warns(UserWarning, match="fill value will overlap with valid data"): + img.save(tmp.name, fill_value=128) with rio.open(tmp.name) as f: file_data = f.read() assert file_data.shape == (3, 5, 5) # no alpha band @@ -985,7 +986,8 @@ def test_save_geotiff_float(self): # float input with fill value saved to int16 (signed!) with NamedTemporaryFile(suffix='.tif') as tmp: - img.save(tmp.name, dtype=np.int16, fill_value=-128) + with pytest.warns(UserWarning, match="fill value will overlap with valid data"): + img.save(tmp.name, dtype=np.int16, fill_value=-128) with rio.open(tmp.name) as f: file_data = f.read() assert file_data.shape == (3, 5, 5) # no alpha band