From 88573ba48ac4ef82b2a3bdfb8fc84320b0341f7e Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Tue, 17 Dec 2024 08:23:09 -0700 Subject: [PATCH] add datetime property test --- properties/test_encode_decode.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/properties/test_encode_decode.py b/properties/test_encode_decode.py index e7eece7e81e..211c33ff6b5 100644 --- a/properties/test_encode_decode.py +++ b/properties/test_encode_decode.py @@ -11,10 +11,12 @@ # isort: split import hypothesis.extra.numpy as npst +import hypothesis.strategies as st import numpy as np from hypothesis import given import xarray as xr +from xarray.coding.times import _parse_iso8601_without_reso from xarray.testing.strategies import variables @@ -43,3 +45,10 @@ def test_CFScaleOffset_coder_roundtrip(original) -> None: coder = xr.coding.variables.CFScaleOffsetCoder() roundtripped = coder.decode(coder.encode(original)) xr.testing.assert_identical(original, roundtripped) + + +# TODO: add cftime.datetime +@given(dt=st.datetimes()) +def test_iso8601_decode(dt): + iso = dt.isoformat() + assert dt == _parse_iso8601_without_reso(type(dt), iso)