MCPcopy
hub / github.com/pydata/xarray / test_default_engine_h5netcdf

Function test_default_engine_h5netcdf

xarray/tests/test_backends_api.py:84–101  ·  view source on GitHub ↗

Test the default netcdf engine when h5netcdf is the only importable module.

(monkeypatch)

Source from the content-addressed store, hash-verified

82
83@requires_h5netcdf
84def test_default_engine_h5netcdf(monkeypatch):
85 """Test the default netcdf engine when h5netcdf is the only importable module."""
86
87 monkeypatch.delitem(sys.modules, "netCDF4", raising=False)
88 monkeypatch.delitem(sys.modules, "scipy", raising=False)
89 monkeypatch.setattr(sys, "meta_path", [])
90
91 engine = get_default_netcdf_write_engine("", format=None)
92 assert engine == "h5netcdf"
93
94 with pytest.raises(
95 ValueError,
96 match=re.escape(
97 "cannot write NetCDF files with format='NETCDF3_CLASSIC' because "
98 "none of the suitable backend libraries (SUITABLE_BACKENDS) are installed"
99 ).replace("SUITABLE_BACKENDS", r"(scipy, netCDF4)|(netCDF4, scipy)"),
100 ):
101 get_default_netcdf_write_engine("", format="NETCDF3_CLASSIC")
102
103
104def test_default_engine_nczarr_no_netcdf4_python(monkeypatch):

Callers

nothing calls this directly

Calls 2

replaceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…