Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions lib/iris/tests/integration/netcdf/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,39 +487,35 @@ def test_path_string_save_same(self):
@tests.skip_data
class TestWarningRepeats(tests.IrisTest):
def test_datum_once(self):
fnames = [
"false_east_north_merc.nc",
"non_unit_scale_factor_merc.nc",
"toa_brightness_temperature.nc",
]
fpaths = [
tests.get_data_path(("NetCDF", "mercator", fname)) for fname in fnames
]
"""Tests for warnings being duplicated.

with warnings.catch_warnings():
warnings.simplefilter("default")
with warnings.catch_warnings(record=True) as record:
for fpath in fpaths:
iris.load(fpath)
assert len(record) == 1
Notes
-----
This test relies on `iris.load` throwing a warning. This warning might
be removed in the future, in which case `assert len(record) == 2 should`
be change to `assert len(record) == 1`.

def test_datum_default(self):
toa_brightness_temperature.nc has lazy data, and triggers a
specific part of dask which contains a `catch_warnings()` call,
so has been removed from the `fnames` list.

"""
#
fnames = [
"false_east_north_merc.nc",
"non_unit_scale_factor_merc.nc",
"toa_brightness_temperature.nc",
#
]
fpaths = [
tests.get_data_path(("NetCDF", "mercator", fname)) for fname in fnames
]

with warnings.catch_warnings():
with warnings.catch_warnings(record=True) as record:
warnings.simplefilter("default")
with pytest.warns() as record:
iris.load_cube(fpaths[0])
iris.load_cube(fpaths[1])
iris.load_cube(fpaths[2])
assert len(record) == 3
for fpath in fpaths:
iris.load(fpath)
warnings.warn("Dummy warning")
assert len(record) == 2


if __name__ == "__main__":
Expand Down