summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_strftime.py
diff options
context:
space:
mode:
authorTim Golden <mail@timgolden.me.uk>2013-11-12 12:48:20 (GMT)
committerTim Golden <mail@timgolden.me.uk>2013-11-12 12:48:20 (GMT)
commitbbe268f58334ec87940094f18dd2e13d1ef2ca70 (patch)
treedf1f0106b936677abb086dd69f7fb52c9000df77 /Lib/test/test_strftime.py
parentdfcd69467489b940232adb5c82dd91aab4a25406 (diff)
parent6e51b8ff0f1a2210548b3ce18e6ba840e0a3c8ae (diff)
downloadcpython-bbe268f58334ec87940094f18dd2e13d1ef2ca70.zip
cpython-bbe268f58334ec87940094f18dd2e13d1ef2ca70.tar.gz
cpython-bbe268f58334ec87940094f18dd2e13d1ef2ca70.tar.bz2
Issue13674 Correct crash with strftime %y format under Windows
Diffstat (limited to 'Lib/test/test_strftime.py')
-rw-r--r--Lib/test/test_strftime.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py
index 6510c36..d3f80c6 100644
--- a/Lib/test/test_strftime.py
+++ b/Lib/test/test_strftime.py
@@ -177,5 +177,31 @@ class StrftimeTest(unittest.TestCase):
print(" Expected %s, but got %s" % (e[1], result))
+class Y1900Tests(unittest.TestCase):
+ """A limitation of the MS C runtime library is that it crashes if
+ a date before 1900 is passed with a format string containing "%y"
+ """
+
+ @unittest.skipUnless(sys.platform == "win32", "Only applies to Windows")
+ def test_y_before_1900_win(self):
+ with self.assertRaises(ValueError):
+ time.strftime("%y", (1899, 1, 1, 0, 0, 0, 0, 0, 0))
+
+ @unittest.skipIf(sys.platform == "win32", "Doesn't apply on Windows")
+ def test_y_before_1900_nonwin(self):
+ self.assertEquals(
+ time.strftime("%y", (1899, 1, 1, 0, 0, 0, 0, 0, 0)), "99")
+
+ def test_y_1900(self):
+ self.assertEquals(
+ time.strftime("%y", (1900, 1, 1, 0, 0, 0, 0, 0, 0)), "00")
+
+ def test_y_after_1900(self):
+ self.assertEquals(
+ time.strftime("%y", (2013, 1, 1, 0, 0, 0, 0, 0, 0)), "13")
+
+def test_main():
+ support.run_unittest(StrftimeTest, Y1900Tests)
+
if __name__ == '__main__':
unittest.main()