mirror of
https://github.com/rasterio/rasterio.git
synced 2025-12-08 17:36:12 +00:00
* 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
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
"""Tests of dataset connection sharing"""
|
|
|
|
import rasterio
|
|
|
|
from .conftest import requires_gdal2
|
|
|
|
|
|
@requires_gdal2
|
|
def test_sharing_on(capfd, path_rgb_byte_tif):
|
|
"""Datasets are shared"""
|
|
with rasterio.Env() as env:
|
|
|
|
# Opens a new file.
|
|
with rasterio.open(path_rgb_byte_tif) as srcx:
|
|
env._dump_open_datasets()
|
|
captured = capfd.readouterr()
|
|
assert "1 N GTiff" in captured.err
|
|
assert "1 S GTiff" not in captured.err
|
|
|
|
# Does not open a new file.
|
|
with rasterio.open(path_rgb_byte_tif, sharing=True) as srcy:
|
|
env._dump_open_datasets()
|
|
captured = capfd.readouterr()
|
|
assert "1 N GTiff" in captured.err
|
|
assert "1 S GTiff" in captured.err
|
|
|
|
|
|
@requires_gdal2
|
|
def test_sharing_off(capfd, path_rgb_byte_tif):
|
|
"""Datasets are not shared"""
|
|
with rasterio.Env() as env:
|
|
|
|
# Opens a new file.
|
|
with rasterio.open(path_rgb_byte_tif, sharing=False) as srcx:
|
|
env._dump_open_datasets()
|
|
captured = capfd.readouterr()
|
|
assert "1 N GTiff" in captured.err
|
|
assert "1 S GTiff" not in captured.err
|
|
|
|
# Opens a new file.
|
|
with rasterio.open(path_rgb_byte_tif, sharing=False) as srcy:
|
|
env._dump_open_datasets()
|
|
captured = capfd.readouterr()
|
|
assert captured.err.count("1 N GTiff") == 2
|
|
assert "1 S GTiff" not in captured.err
|