Skip to content

Commit

Permalink
Match error messages for latest xarray version
Browse files Browse the repository at this point in the history
  • Loading branch information
peanutfun committed Dec 12, 2023
1 parent 3851c48 commit 67ff553
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions climada/hazard/test/test_base_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,13 @@ def test_missing_dims(self):
ds = ds.drop_vars("time")
with self.assertRaises(RuntimeError) as cm:
Hazard.from_xarray_raster(ds, "", "")
self.assertIn(
"Dataset is missing dimension/coordinate: time", str(cm.exception)
)
self.assertIn("No variable named 'time'", str(cm.exception))

# Expand time again
ds = ds.expand_dims(time=[np.datetime64("2022-01-01")])
hazard = Hazard.from_xarray_raster(ds, "", "")
self._assert_default_types(hazard)
np.testing.assert_array_equal(
hazard.event_name, ["2022-01-01"]
)
np.testing.assert_array_equal(hazard.event_name, ["2022-01-01"])
np.testing.assert_array_equal(
hazard.date, [dt.datetime(2022, 1, 1).toordinal()]
)
Expand Down Expand Up @@ -575,9 +571,7 @@ def test_errors(self):
"",
coordinate_vars=dict(latitude="lalalatitude"),
)
self.assertIn(
"Dataset is missing dimension/coordinate: lalalatitude.", str(cm.exception)
)
self.assertIn("No variable named 'lalalatitude'", str(cm.exception))


# Execute Tests
Expand Down

0 comments on commit 67ff553

Please sign in to comment.