Test the default netcdf engine when h5netcdf is the only importable module.
(monkeypatch)
| 82 | |
| 83 | @requires_h5netcdf |
| 84 | def 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 | |
| 104 | def test_default_engine_nczarr_no_netcdf4_python(monkeypatch): |
nothing calls this directly
no test coverage detected
searching dependent graphs…