Skip to content

Commit

Permalink
Add tests for invalid units and reference date
Browse files Browse the repository at this point in the history
  • Loading branch information
gcaria committed May 12, 2021
1 parent e56ede2 commit a46936f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions xarray/tests/test_coding_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,12 @@ def test_encode_cf_datetime_overflow(shape):
roundtrip = decode_cf_datetime(num, units, calendar)
np.testing.assert_array_equal(dates, roundtrip)

with pytest.raises(ValueError, match="invalid time units"):
encode_cf_datetime([1, 2, 3], units="moments since 2000-01-01")

with pytest.raises(ValueError, match="invalid reference date"):
encode_cf_datetime([1, 2, 3], units="days since NO_YEAR")


def test_encode_cf_datetime_pandas_min():
# GH 2623
Expand Down

0 comments on commit a46936f

Please sign in to comment.