summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_datetime.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-12-22 20:58:42 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-12-22 20:58:42 (GMT)
commitd6844155725af2eb53a9bc5beb74521c4d212365 (patch)
tree36e7a57691b30b91562fd54149777938ec5a4d36 /Lib/test/test_datetime.py
parent83b85f1d6cce999e0d85f669df71a520632a4c87 (diff)
downloadcpython-d6844155725af2eb53a9bc5beb74521c4d212365.zip
cpython-d6844155725af2eb53a9bc5beb74521c4d212365.tar.gz
cpython-d6844155725af2eb53a9bc5beb74521c4d212365.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_datetime.py')
-rw-r--r--Lib/test/test_datetime.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index ca26872..6838e47 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -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