From 6dd080f21f332815b401ad3f51a39365d09fb56e Mon Sep 17 00:00:00 2001 From: Giacomo Caria <44147817+gcaria@users.noreply.github.com> Date: Fri, 14 May 2021 12:06:12 +0200 Subject: [PATCH] Move encode expected test failures to own function (#5308) --- xarray/tests/test_coding_times.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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")