Skip to content

Commit

Permalink
Check for expected fill value warning
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Dec 15, 2023
1 parent d15e1ca commit 2f11fc9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions trollimage/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2f11fc9

Please sign in to comment.