From 31c5dd6b19e455fa2ab3dc1fc5497f152ce9bb7a Mon Sep 17 00:00:00 2001 From: Alexander Belopolsky Date: Tue, 11 Jan 2011 01:35:22 +0000 Subject: [PATCH] Make mktime test more robust. --- Lib/test/test_time.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index d6492320107..574a867ce20 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -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