Skip to content

Commit a46936f

Browse files
committed
Add tests for invalid units and reference date
1 parent e56ede2 commit a46936f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

xarray/tests/test_coding_times.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,12 @@ def test_encode_cf_datetime_overflow(shape):
823823
roundtrip = decode_cf_datetime(num, units, calendar)
824824
np.testing.assert_array_equal(dates, roundtrip)
825825

826+
with pytest.raises(ValueError, match="invalid time units"):
827+
encode_cf_datetime([1, 2, 3], units="moments since 2000-01-01")
828+
829+
with pytest.raises(ValueError, match="invalid reference date"):
830+
encode_cf_datetime([1, 2, 3], units="days since NO_YEAR")
831+
826832

827833
def test_encode_cf_datetime_pandas_min():
828834
# GH 2623

0 commit comments

Comments
 (0)