]> granicus.if.org Git - python/commitdiff
Make mktime test more robust.
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>
Tue, 11 Jan 2011 01:35:22 +0000 (01:35 +0000)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>
Tue, 11 Jan 2011 01:35:22 +0000 (01:35 +0000)
Lib/test/test_time.py

index d64923201071ed0b6a394d069fe7c94e87387ef1..574a867ce209ab0339e2a9e9c9553fd45b695435 100644 (file)
@@ -348,9 +348,13 @@ class _Test4dYear(_BaseYearTest):
             except (OverflowError, ValueError):
                 pass
             self.assertEqual(time.mktime(tt), t)
-        # Hopefully year = -1 is enough to make OS mktime fail
-        self.assertRaises(OverflowError, time.mktime,
-                          (-1, 1, 1, 0, 0, 0, -1, -1, -1))
+        # It may not be possible to reliably make mktime return error
+        # on all platfom.  This will make sure that no other exception
+        # than OverflowError is raised for an extreme value.
+        try:
+            time.mktime((-1, 1, 1, 0, 0, 0, -1, -1, -1))
+        except OverflowError:
+            pass
 
 class TestAsctimeAccept2dYear(_TestAsctimeYear, _Test2dYear):
     pass