mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
I give up: unless I write my own strftime by hand, datetime just can't
be trusted with years before 1900, so now we raise ValueError if a date or datetime or datetimetz .strftime() method is called with a year before 1900.
This commit is contained in:
parent
83b85f1d6c
commit
d684415572
2 changed files with 31 additions and 0 deletions
|
@ -868,6 +868,12 @@ class TestDate(unittest.TestCase):
|
|||
self.failUnless(self.theclass.min)
|
||||
self.failUnless(self.theclass.max)
|
||||
|
||||
def test_srftime_out_of_range(self):
|
||||
# For nasty technical reasons, we can't handle years before 1900.
|
||||
cls = self.theclass
|
||||
self.assertEqual(cls(1900, 1, 1).strftime("%Y"), "1900")
|
||||
for y in 1, 49, 51, 99, 100, 1000, 1899:
|
||||
self.assertRaises(ValueError, cls(y, 1, 1).strftime, "%Y")
|
||||
#############################################################################
|
||||
# datetime tests
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue