Skip to content

Commit 7a68568

Browse files
dtsongclaude
andcommitted
fix: remove incorrect skipif and add missing edge case tests
- Remove skipif on test_nanosecond_precision_with_timezone — after truncation the string is valid on Python 3.10 - Add test_nanosecond_precision_with_z_suffix (combined Z + truncation) - Add test_trailing_dot_raises (malformed fractional seconds) - Remove unused sys import Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3d513b4 commit 7a68568

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/test_datetime_parsing.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from datetime import datetime, timedelta, timezone
32

43
import pytest
@@ -43,14 +42,19 @@ def test_z_suffix_utc(self):
4342
result = _parse_datetime("2022-06-03T12:24:35Z")
4443
assert result == datetime(2022, 6, 3, 12, 24, 35, tzinfo=timezone.utc)
4544

46-
@pytest.mark.skipif(
47-
sys.version_info < (3, 11), reason="fromisoformat needs 3.11+ for fractional seconds with tz offset"
48-
)
4945
def test_nanosecond_precision_with_timezone(self):
5046
result = _parse_datetime("2022-06-03T12:24:35.123456789+05:30")
5147
expected_tz = timezone(timedelta(hours=5, minutes=30))
5248
assert result == datetime(2022, 6, 3, 12, 24, 35, 123456, tzinfo=expected_tz)
5349

50+
def test_nanosecond_precision_with_z_suffix(self):
51+
result = _parse_datetime("2022-06-03T12:24:35.123456789Z")
52+
assert result == datetime(2022, 6, 3, 12, 24, 35, 123456, tzinfo=timezone.utc)
53+
54+
def test_trailing_dot_raises(self):
55+
with pytest.raises(ValueError):
56+
_parse_datetime("2022-06-03T12:24:35.")
57+
5458
def test_invalid_string_raises(self):
5559
with pytest.raises(ValueError):
5660
_parse_datetime("not-a-date")

0 commit comments

Comments
 (0)