rasterio/tests/test_creation_options.py
Sean Gillies 87a582a391
Update code to Python 3.9 usage (#3132)
* Run pyupgrade --py39-up

* Run darker on previous pyupgrade changes
2024-08-10 18:22:54 -06:00

26 lines
803 B
Python

"""Tests of creation option behavior"""
import logging
import rasterio
from rasterio.profiles import DefaultGTiffProfile
def test_warning(tmpdir, caplog):
"""Be warned about invalid creation options"""
profile = DefaultGTiffProfile(
count=1, height=256, width=256, compression="lolwut", foo="bar"
)
with rasterio.Env(GDAL_VALIDATE_CREATION_OPTIONS=True):
rasterio.open(str(tmpdir.join("test.tif")), "w", **profile)
assert {
"CPLE_NotSupported in driver GTiff does not support creation option COMPRESSION",
"CPLE_NotSupported in driver GTiff does not support creation option FOO",
} <= {
rec.message
for rec in caplog.records
if rec.levelno == logging.WARNING and rec.name == "rasterio._env"
}