diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-01-08 02:00:24 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-01-08 02:00:24 (GMT) |
commit | 736913269e19d4ac8bcf154921783554456ea681 (patch) | |
tree | b4f6e1f3ca786821f423983fcf8296af45bb9116 | |
parent | 73ea29cb039318a70b3cbc9ab2697308a470b5ba (diff) | |
download | cpython-736913269e19d4ac8bcf154921783554456ea681.zip cpython-736913269e19d4ac8bcf154921783554456ea681.tar.gz cpython-736913269e19d4ac8bcf154921783554456ea681.tar.bz2 |
Issue #1777412: test large years value for strftime('%Y')
-rw-r--r-- | Lib/test/test_time.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index c2fd9ff..3db25bb 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -280,7 +280,7 @@ class _TestAsctimeYear: return time.asctime((y,) + (0,) * 8).split()[-1] def test_large_year(self): - # Check that it doesn't crash with year > 9999 + # Check that it doesn't crash for year > 9999 self.assertEqual(self.yearstr(12345), '12345') self.assertEqual(self.yearstr(123456789), '123456789') @@ -289,16 +289,21 @@ class _TestStrftimeYear: return time.strftime('%Y', (y,) + (0,) * 8).split()[-1] def test_large_year(self): - # Just check that it doesn't crash with year > 9999: it may or may not - # raise an error depending on the OS and compiler + # Check that it doesn't crash for year > 9999 try: - self.yearstr(12345) + text = self.yearstr(12345) except ValueError: + # If Python is compiled with Visual Studio, + # year is limited to [1; 9999] pass + else: + self.assertEqual(text, '12345') try: - self.yearstr(123456) + text = self.yearstr(123456789) except ValueError: pass + else: + self.assertEqual(text, '123456789') class _Test2dYear(_BaseYearTest): accept2dyear = 1 |