(
five_digit_year: bool, sign: str, string: str, expected: dict
)
| 139 | ) |
| 140 | @pytest.mark.parametrize("sign", ["", "+", "-"], ids=["None", "plus", "minus"]) |
| 141 | def 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 = [ |
nothing calls this directly
no test coverage detected
searching dependent graphs…