rasterio/tests/test_open_options.py
Sean Gillies 9e30d22d6d
Switch sharing kwarg default to False (#1775)
* Switch sharing kwarg default to False

Resolves #1705

* Replace GDALOpenShared with GDALOpen except in one shim

* Revert two open_dataset to GDALOpen

* Run tests under gdb

* Increment ref count in WarpedVRTBase

* Open a new dataset handle in WarpedVRT

* Remove gdb

* Remove exceptions from open_dataset in _shim1

Makes usage much easier

* Fix in-memory dataset leaks in _reproject
2019-09-13 08:05:14 -06:00

31 lines
936 B
Python

"""Tests of dataset opening options and driver choice"""
import pytest
import rasterio
from rasterio.transform import Affine
from .conftest import requires_only_gdal1, requires_gdal2, requires_gdal22
@requires_gdal2
def test_fail_with_missing_driver():
"""Fail to open a GeoTIFF without the GTiff driver"""
with pytest.raises(rasterio.errors.RasterioIOError):
rasterio.open('tests/data/RGB.byte.tif', driver='BMP')
@requires_gdal2
def test_open_specific_driver():
"""Open a GeoTIFF with the GTiff driver"""
with rasterio.open('tests/data/RGB.byte.tif', driver='GTiff') as src:
assert src.count == 3
@requires_gdal22
def test_open_specific_driver_with_options():
"""Open a GeoTIFF with the GTiff driver and GEOREF_SOURCES option"""
with rasterio.open(
'tests/data/RGB.byte.tif', driver='GTiff', GEOREF_SOURCES='NONE') as src:
assert src.transform == Affine.identity()