Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Fix tests for rasterio 1.4.3 #838

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: pre-commit/[email protected]

docker_tests:
Expand Down
1 change: 1 addition & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
TEST_INPUT_DATA_DIR = os.path.join(TEST_DATA_DIR, "input")
TEST_COMPARE_DATA_DIR = os.path.join(TEST_DATA_DIR, "compare")
RASTERIO_GE_14 = version.parse(rasterio.__version__) >= version.parse("1.4.0")
RASTERIO_GE_143 = version.parse(rasterio.__version__) >= version.parse("1.4.3")
GDAL_GE_36 = version.parse(rasterio.__gdal_version__) >= version.parse("3.6.0")
GDAL_GE_361 = version.parse(rasterio.__gdal_version__) >= version.parse("3.6.1")
GDAL_GE_364 = version.parse(rasterio.__gdal_version__) >= version.parse("3.6.4")
Expand Down
17 changes: 12 additions & 5 deletions test/integration/test_integration__io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import contextlib
import io
import itertools
import logging
import os
import pickle
import shutil
Expand Down Expand Up @@ -863,13 +864,19 @@ def test_http_url():
assert isinstance(actual.data, dask.array.Array)


def test_rasterio_environment():
def test_rasterio_environment(tmp_path):
log = logging.getLogger("rasterio._env")
log.setLevel(logging.DEBUG)
logfile = tmp_path / "file.log"
fh = logging.FileHandler(logfile)
log.addHandler(fh)
with create_tmp_geotiff() as (tmp_file, expected):
# Should fail with error since suffix not allowed
with pytest.raises(Exception):
with rasterio.Env(GDAL_SKIP="GTiff"):
with rioxarray.open_rasterio(tmp_file) as actual:
assert_allclose(actual, expected)
with rasterio.Env(CPL_DEBUG=True):
with rioxarray.open_rasterio(tmp_file) as actual:
assert_allclose(actual.load(), expected)

assert f"GDAL: GDALOpen({tmp_file}" in logfile.read_text()


@pytest.mark.parametrize("band_as_variable", [True, False])
Expand Down
4 changes: 2 additions & 2 deletions test/integration/test_integration_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from rioxarray import open_rasterio
from rioxarray.merge import merge_arrays, merge_datasets
from test.conftest import RASTERIO_GE_14, TEST_INPUT_DATA_DIR
from test.conftest import RASTERIO_GE_14, RASTERIO_GE_143, TEST_INPUT_DATA_DIR


@pytest.mark.parametrize("squeeze", [True, False])
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_merge__different_crs(dataset):
(-7300984.0238134, 5003618.5908794, -7224054.1109682, 5050108.6101528),
)
assert merged.rio.shape == (84, 139)
if RASTERIO_GE_14:
if RASTERIO_GE_14 and not RASTERIO_GE_143:
assert_almost_equal(test_sum, -126821853)
else:
assert_almost_equal(test_sum, -131734881)
Expand Down
Loading