MCPcopy Index your code
hub / github.com/pydata/xarray / test_parse_iso8601_like

Function test_parse_iso8601_like

xarray/tests/test_cftimeindex.py:141–164  ·  view source on GitHub ↗
(
    five_digit_year: bool, sign: str, string: str, expected: dict
)

Source from the content-addressed store, hash-verified

139)
140@pytest.mark.parametrize("sign", ["", "+", "-"], ids=["None", "plus", "minus"])
141def test_parse_iso8601_like(
142 five_digit_year: bool, sign: str, string: str, expected: dict
143) -> None:
144 pre = "1" if five_digit_year else ""
145 datestring = sign + pre + string
146 result = parse_iso8601_like(datestring)
147 expected = expected.copy()
148 expected.update(year=sign + pre + expected["year"])
149 assert result == expected
150
151 # check malformed single digit addendum
152 # this check is only performed when we have at least "hour" given
153 # like "1999010101", where a single added digit should raise
154 # for "1999" (year), "199901" (month) and "19990101" (day)
155 # and a single added digit the string would just be interpreted
156 # as having a 5-digit year.
157 if result["microsecond"] is None and result["hour"] is not None:
158 with pytest.raises(ValueError):
159 parse_iso8601_like(datestring + "3")
160
161 # check malformed floating point addendum
162 if result["second"] is None or result["microsecond"] is not None:
163 with pytest.raises(ValueError):
164 parse_iso8601_like(datestring + ".3")
165
166
167_CFTIME_CALENDARS = [

Callers

nothing calls this directly

Calls 3

parse_iso8601_likeFunction · 0.90
copyMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…