summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_time.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-01-08 03:06:52 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-01-08 03:06:52 (GMT)
commit301f1217ac18e612c71e18f8fbebbdf31727eb47 (patch)
tree5427416790cacdadf4cec3ccc2978c925ef2679f /Lib/test/test_time.py
parentaf5aee57c98d4529218c517ee6d73c3f78bc6738 (diff)
downloadcpython-301f1217ac18e612c71e18f8fbebbdf31727eb47.zip
cpython-301f1217ac18e612c71e18f8fbebbdf31727eb47.tar.gz
cpython-301f1217ac18e612c71e18f8fbebbdf31727eb47.tar.bz2
Issue #1777412: Remove all limits on tm_year from time.strftime()
The buildbots will tell us which platform does support or not negative years.
Diffstat (limited to 'Lib/test/test_time.py')
-rw-r--r--Lib/test/test_time.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index 9f36c9d..baabfbb 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -294,21 +294,13 @@ class _TestStrftimeYear:
text = self.yearstr(12345)
except ValueError:
# strftime() is limited to [1; 9999] with Visual Studio
- pass
- else:
- # Issue #10864: OpenIndiana is limited to 4 digits, but Python
- # doesn't raise a ValueError
- #self.assertEqual(text, '12345')
- self.assertIn(text, ('2345', '12345'))
- try:
- text = self.yearstr(123456789)
- except ValueError:
- pass
- else:
- # Issue #10864: OpenIndiana is limited to 4 digits, but Python
- # doesn't raise a ValueError
- #self.assertEqual(text, '123456789')
- self.assertIn(text, ('123456789', '6789'))
+ return
+ # Issue #10864: OpenIndiana is limited to 4 digits,
+ # but Python doesn't raise a ValueError
+ #self.assertEqual(text, '12345')
+ #self.assertEqual(self.yearstr(123456789), '123456789')
+ self.assertIn(text, ('2345', '12345'))
+ self.assertIn(self.yearstr(123456789), ('123456789', '6789'))
class _Test2dYear(_BaseYearTest):
accept2dyear = 1
@@ -336,6 +328,17 @@ class _Test4dYear(_BaseYearTest):
self.assertIn(self.yearstr(999), ('999', '0999'))
self.assertEqual(self.yearstr(9999), '9999')
+ def test_negative(self):
+ try:
+ text = self.yearstr(-1)
+ except ValueError:
+ # strftime() is limited to [1; 9999] with Visual Studio
+ return
+ self.assertIn(text, ('-1', '-001'))
+
+ self.assertEqual(self.yearstr(-1234), '-1234')
+ self.assertEqual(self.yearstr(-123456), '-123456')
+
class TestAsctimeAccept2dYear(_TestAsctimeYear, _Test2dYear):
pass
@@ -346,8 +349,7 @@ class TestAsctime4dyear(_TestAsctimeYear, _Test4dYear):
pass
class TestStrftime4dyear(_TestStrftimeYear, _Test4dYear):
- def test_bounds(self):
- self.assertRaises(ValueError, self.yearstr, 0)
+ pass
class Test2dyearBool(_TestAsctimeYear, _Test2dYear):
accept2dyear = True