Skip to content

Commit

Permalink
Issue #594 harden openeo.testing.results tests
Browse files Browse the repository at this point in the history
Improve compatibility of `openeo.testing.results` tests with multiple xarray/numpy versions
  • Loading branch information
soxofaan committed Jul 19, 2024
1 parent 428afa6 commit 83fb7a9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/testing/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import pytest
import xarray

from openeo.capabilities import ComparableVersion
from openeo.rest.job import DEFAULT_JOB_RESULTS_FILENAME
from openeo.testing.results import (
_compare_xarray_dataarray,
Expand Down Expand Up @@ -108,7 +109,7 @@ def test_simple_dims_mismatch(self, actual, expected_issues):
[
"Coordinates mismatch for dimension 'x': [111 222] != [11 22]",
dirty_equals.IsStr(
regex=r"Left and right DataArray objects are not close.*Differing coordinates:.*L \* x\s+\(x\) int64 111 222.*R \* x\s+\(x\) int64 11 22",
regex=r"Left and right DataArray objects are not close.*Differing coordinates:.*L \* x\s+\(x\).*?111 222.*R \* x\s+\(x\).*?11 22",
regex_flags=re.DOTALL,
),
],
Expand Down Expand Up @@ -306,6 +307,10 @@ def test_assert_xarray_dataset_allclose_tolerance(self, kwargs, assertion_error)
with raises_assertion_error_or_not(message=assertion_error):
assert_xarray_dataset_allclose(actual=actual, expected=expected, **kwargs)

@pytest.mark.skipif(
ComparableVersion(xarray.__version__) < "2024.07.0" and ComparableVersion(numpy.__version__) >= "2.0.0",
reason="This test doesn't work due to numpy 2 compatibility issue in xarray below 2024.7.0",
)
def test_assert_xarray_dataset_allclose_empty_coords_handling(self):
expected = xarray.Dataset(
{
Expand Down

0 comments on commit 83fb7a9

Please sign in to comment.