-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
101 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Tests for fix of #1504""" | ||
|
||
import rasterio | ||
|
||
from .conftest import requires_gdal2 | ||
|
||
|
||
@requires_gdal2 | ||
def test_overview_levels(path_cogeo_tif): | ||
"""With sharing turned off, problem noted in #1504 vanishes""" | ||
olevel = 0 | ||
with rasterio.open(path_cogeo_tif, overview_level=olevel) as src: | ||
assert src.shape == (512, 512) | ||
|
||
olevel = 1 | ||
with rasterio.open(path_cogeo_tif, sharing=False, overview_level=olevel) as src: | ||
assert src.shape == (256, 256) | ||
|
||
olevel = 2 | ||
with rasterio.open(path_cogeo_tif, sharing=False, overview_level=olevel) as src: | ||
assert src.shape == (128, 128) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""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, 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 | ||
|
||
# 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 | ||
|
||
# Does not open 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 |