Issue #1777412: fix test_time for Mac OS X and OpenIndiana

This commit is contained in:
Victor Stinner 2011-01-08 02:46:33 +00:00
parent 736913269e
commit af5aee57c9
1 changed files with 14 additions and 9 deletions

View File

@ -293,17 +293,22 @@ class _TestStrftimeYear:
try: try:
text = self.yearstr(12345) text = self.yearstr(12345)
except ValueError: except ValueError:
# If Python is compiled with Visual Studio, # strftime() is limited to [1; 9999] with Visual Studio
# year is limited to [1; 9999]
pass pass
else: else:
self.assertEqual(text, '12345') # 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: try:
text = self.yearstr(123456789) text = self.yearstr(123456789)
except ValueError: except ValueError:
pass pass
else: else:
self.assertEqual(text, '123456789') # Issue #10864: OpenIndiana is limited to 4 digits, but Python
# doesn't raise a ValueError
#self.assertEqual(text, '123456789')
self.assertIn(text, ('123456789', '6789'))
class _Test2dYear(_BaseYearTest): class _Test2dYear(_BaseYearTest):
accept2dyear = 1 accept2dyear = 1
@ -324,11 +329,11 @@ class _Test4dYear(_BaseYearTest):
accept2dyear = 0 accept2dyear = 0
def test_year(self): def test_year(self):
self.assertEqual(self.yearstr(1), '1') self.assertIn(self.yearstr(1), ('1', '0001'))
self.assertEqual(self.yearstr(69), '69') self.assertIn(self.yearstr(68), ('68', '0068'))
self.assertEqual(self.yearstr(68), '68') self.assertIn(self.yearstr(69), ('69', '0069'))
self.assertEqual(self.yearstr(99), '99') self.assertIn(self.yearstr(99), ('99', '0099'))
self.assertEqual(self.yearstr(999), '999') self.assertIn(self.yearstr(999), ('999', '0999'))
self.assertEqual(self.yearstr(9999), '9999') self.assertEqual(self.yearstr(9999), '9999')
class TestAsctimeAccept2dYear(_TestAsctimeYear, _Test2dYear): class TestAsctimeAccept2dYear(_TestAsctimeYear, _Test2dYear):