Skip to content
forked from pydata/xarray

Commit

Permalink
ignore h5py 2.10.0 warnings and fix invalid_netcdf warning test. (pyd…
Browse files Browse the repository at this point in the history
…ata#3301)

* ignore h5py 2.10.0 warnings and fix invalid_netcdf warning test.

* Better fix.

* fix fix.

* remove comment.

* Add docs.

* Revert "Add docs."

This reverts commit 14ae0b1.
  • Loading branch information
dcherian authored and shoyer committed Sep 13, 2019
1 parent 36cd02c commit e90e8bc
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2163,6 +2163,7 @@ def test_encoding_unlimited_dims(self):

@requires_h5netcdf
@requires_netCDF4
@pytest.mark.filterwarnings("ignore:use make_scale(name) instead")
class TestH5NetCDFData(NetCDF4Base):
engine = "h5netcdf"

Expand All @@ -2173,16 +2174,25 @@ def create_store(self):

@pytest.mark.filterwarnings("ignore:complex dtypes are supported by h5py")
@pytest.mark.parametrize(
"invalid_netcdf, warns, num_warns",
"invalid_netcdf, warntype, num_warns",
[(None, FutureWarning, 1), (False, FutureWarning, 1), (True, None, 0)],
)
def test_complex(self, invalid_netcdf, warns, num_warns):
def test_complex(self, invalid_netcdf, warntype, num_warns):
expected = Dataset({"x": ("y", np.ones(5) + 1j * np.ones(5))})
save_kwargs = {"invalid_netcdf": invalid_netcdf}
with pytest.warns(warns) as record:
with pytest.warns(warntype) as record:
with self.roundtrip(expected, save_kwargs=save_kwargs) as actual:
assert_equal(expected, actual)
assert len(record) == num_warns

recorded_num_warns = 0
if warntype:
for warning in record:
if issubclass(warning.category, warntype) and (
"complex dtypes" in str(warning.message)
):
recorded_num_warns += 1

assert recorded_num_warns == num_warns

def test_cross_engine_read_write_netcdf4(self):
# Drop dim3, because its labels include strings. These appear to be
Expand Down Expand Up @@ -2451,6 +2461,7 @@ def skip_if_not_engine(engine):


@requires_dask
@pytest.mark.filterwarnings("ignore:use make_scale(name) instead")
def test_open_mfdataset_manyfiles(
readengine, nfiles, parallel, chunks, file_cache_maxsize
):
Expand Down

0 comments on commit e90e8bc

Please sign in to comment.