diff --git a/xarray/tests/test_coding_times.py b/xarray/tests/test_coding_times.py index 9f8ccf2edcf..f0882afe367 100644 --- a/xarray/tests/test_coding_times.py +++ b/xarray/tests/test_coding_times.py @@ -823,9 +823,12 @@ def test_encode_cf_datetime_overflow(shape): roundtrip = decode_cf_datetime(num, units, calendar) np.testing.assert_array_equal(dates, roundtrip) + +def test_encode_expected_failures(): + + dates = pd.date_range("2000", periods=3) with pytest.raises(ValueError, match="invalid time units"): encode_cf_datetime(dates, units="days after 2000-01-01") - with pytest.raises(ValueError, match="invalid reference date"): encode_cf_datetime(dates, units="days since NO_YEAR")