From a095eb70939f62b64b281758eb20953765467ddc Mon Sep 17 00:00:00 2001 From: Manuel Reis Date: Wed, 1 Jul 2026 18:12:49 +0200 Subject: [PATCH 1/2] Test intergration decode_cf parameter --- data/misc/diff_missing_fill.nc | Bin 0 -> 8240 bytes tests/conftest.py | 8 ++++++++ tests/test_entrypoint.py | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 data/misc/diff_missing_fill.nc diff --git a/data/misc/diff_missing_fill.nc b/data/misc/diff_missing_fill.nc new file mode 100644 index 0000000000000000000000000000000000000000..74e0e4863ba268264fcd47af6be49355dfd2c4dc GIT binary patch literal 8240 zcmeI1%}*0S6u{r^Qqq*Aty4|(hqGHgp&jh z!p-<^Xgv7`;DwVHVq!dd^5(_FBfd8ufVC!=5b-b*wr^+V&71dr^JbXB&Rlk;KXf^y z2ZJEXfhZ#uZy6CC`_uLNg}H1|H{a=ltj!3BE;*!AhIG(KB^ssA)n57psB;0mF?!K@ z3{ltCzsa5f-lL0ppYPTmyRC}9+H#)?^@|DU!EQr?&RJz0j$%T^Pnoyd%>DkDrm>lI zP1EEIQW_?C9L14*a2f((YB7eWF0?jzJX<3CJHkupQQ(grnHf?wAOi(Mi;`bD2^JE?@^?CLgo&3r@Z?U&xnB zb|&Y5nV@z90(?L|v*0j&(xqn|pVvEkZ#W<4l=yrUd|sh-D*uEJaXNKA8_cAE1jD#; zh+M8*)~kEfU)K!h=WBK4$JRJYQMQza&6&@MGUt4tY1gnBbX;eVSu(?ZlSYiJp0lnV zT8sxF{tQP4Leygnv80(y>;=!0P23h1NuCoVPe9)xy}!!NPPfSbMQ^5ghW25aQ=-p! zwc5Q(ZPo1>Lf1UUP|R7Lwqb6i?zP)q<6(JC7@9uZqp3bf9pJgp)e!l#{C?M5rq~RK z;4VRzjFU=93QsRyPORa7*j$)@5k!|g3_+%q&b56(0uY@v|!KO=Eunw zaXiZHLgr4Ka%2u*@$0Q38I(C-S*%$)4Q7pd7=aODP;_RTqLa6sGGj1~K@fv##jmto z{|H9atGkW1*K9zL`dOxd)s?n9of#X{-Tx4pARlBs*Z-V_Y>He9^Ao9@w-;MYJmP&1 z&pC<2OrB5)Q2X6-_bUCroTheck~_?KS*`Gs6u zsKkXEK;E$UD1hCFd{a^pPy`eKML-cy1QY>9KoL*`6ahs*5l{sFKLVT6=u;Yh(t!VQ Mlm5xS19aAZ0z7#%FaQ7m literal 0 HcmV?d00001 diff --git a/tests/conftest.py b/tests/conftest.py index a4d929c..2080b52 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -122,6 +122,14 @@ def sample_cordex_path(data_dir: Path) -> Path: / "pr_EUR-11_NCC-NorESM1-M_rcp85_r1i1p1_GERICS-REMO2015_v2_3hr_200701020130-200701020430.nc" ) +@pytest.fixture +def sample_incoherent_encoding_path(data_dir: Path) -> Path: + """Return path to a incoherent NetCDF file.""" + return ( + data_dir + / "misc/diff_missing_fill.nc" + ) + def pytest_configure(config): """Register custom markers.""" diff --git a/tests/test_entrypoint.py b/tests/test_entrypoint.py index b1aef6d..ccd8e93 100644 --- a/tests/test_entrypoint.py +++ b/tests/test_entrypoint.py @@ -214,6 +214,22 @@ def test_xarray_open_with_freva_engine(self, sample_netcdf_path: Path): assert isinstance(ds, xr.Dataset) ds.close() + @pytest.mark.required_data + def test_decoding(self, sample_incoherent_encoding_path: Path): + with pytest.warns(): + ds = xr.open_dataset(str(sample_incoherent_encoding_path), engine="prism") + assert isinstance(ds, xr.Dataset) + ds.close() + + @pytest.mark.required_data + def test_not_decoding(self, sample_incoherent_encoding_path: Path): + import warnings + with warnings.catch_warnings(): + warnings.simplefilter("error") + ds = xr.open_dataset(str(sample_incoherent_encoding_path), engine="prism", decode_cf=False) + assert isinstance(ds, xr.Dataset) + ds.close() + class TestCustomRegistry: """Tests for custom backend registration.""" From 0db81de7752bc110f13e4008a8f335a7075da1bd Mon Sep 17 00:00:00 2001 From: Manuel Reis Date: Thu, 2 Jul 2026 14:15:12 +0200 Subject: [PATCH 2/2] Format --- tests/conftest.py | 6 ++---- tests/test_entrypoint.py | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 2080b52..512289c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -122,13 +122,11 @@ def sample_cordex_path(data_dir: Path) -> Path: / "pr_EUR-11_NCC-NorESM1-M_rcp85_r1i1p1_GERICS-REMO2015_v2_3hr_200701020130-200701020430.nc" ) + @pytest.fixture def sample_incoherent_encoding_path(data_dir: Path) -> Path: """Return path to a incoherent NetCDF file.""" - return ( - data_dir - / "misc/diff_missing_fill.nc" - ) + return data_dir / "misc/diff_missing_fill.nc" def pytest_configure(config): diff --git a/tests/test_entrypoint.py b/tests/test_entrypoint.py index ccd8e93..7768ac1 100644 --- a/tests/test_entrypoint.py +++ b/tests/test_entrypoint.py @@ -224,9 +224,12 @@ def test_decoding(self, sample_incoherent_encoding_path: Path): @pytest.mark.required_data def test_not_decoding(self, sample_incoherent_encoding_path: Path): import warnings + with warnings.catch_warnings(): warnings.simplefilter("error") - ds = xr.open_dataset(str(sample_incoherent_encoding_path), engine="prism", decode_cf=False) + ds = xr.open_dataset( + str(sample_incoherent_encoding_path), engine="prism", decode_cf=False + ) assert isinstance(ds, xr.Dataset) ds.close()