Skip to content

Commit 54455e2

Browse files
committed
Add failing test for partial date with leap day
Python uses 1900 as the default year if a partial date is parsed with datetime.datetime.strptime. This fails for February 29th because 1900 is not a leap year. This is discussed in #335 and upstream in python/cpython#116179.
1 parent 19b974e commit 54455e2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

test/test_helpers_typing.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,11 @@ def test_yyyy_mm_ddThh_mm_ssz_format(self):
149149
string = "1900-01-02T06:42:17-06:00"
150150
result = string_to_date(string)
151151
self.assertEqual(result, self.zone)
152+
153+
@unittest.expectedFailure
154+
def test_partial_date_with_february_29(self):
155+
# FIXME: this fails because 1900 is not a leap year, see
156+
# https://github.com/python/cpython/pull/116179 for more info.
157+
string = "--02-29"
158+
result = string_to_date(string)
159+
self.assertEqual(result, datetime.datetime(year=1900, month=2, day=29))

0 commit comments

Comments
 (0)