diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2011-11-01 11:56:14 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2011-11-01 11:56:14 (GMT) |
commit | 49ce06858b51ef98c31431436b28d32dd3bd99cd (patch) | |
tree | 718216fee6393090d0fe8538413301ca129a491d /Lib/test/datetimetester.py | |
parent | b6dbc9ee15d5d96ce3fb14f5257b447291b989aa (diff) | |
download | cpython-49ce06858b51ef98c31431436b28d32dd3bd99cd.zip cpython-49ce06858b51ef98c31431436b28d32dd3bd99cd.tar.gz cpython-49ce06858b51ef98c31431436b28d32dd3bd99cd.tar.bz2 |
Strengthen the tests for format '%Y', in relation with issue #13305.
Diffstat (limited to 'Lib/test/datetimetester.py')
-rw-r--r-- | Lib/test/datetimetester.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index f91e8fc..85036aa 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -1291,8 +1291,16 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase): def test_strftime_y2k(self): for y in (1, 49, 70, 99, 100, 999, 1000, 1970): - self.assertIn(self.theclass(y, 1, 1).strftime("%Y"), - [str(y),'%04d' % y]) + d = self.theclass(y, 1, 1) + # Issue 13305: For years < 1000, the value is not always + # padded to 4 digits across platforms. The C standard + # assumes year >= 1900, so it does not specify the number + # of digits. + if d.strftime("%Y") != '%04d' % y: + # Year 42 returns '42', not padded + self.assertEqual(d.strftime("%Y"), '%d' % y) + # '0042' is obtained anyway + self.assertEqual(d.strftime("%4Y"), '%04d' % y) def test_replace(self): cls = self.theclass |