diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2012-01-27 00:03:25 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2012-01-27 00:03:25 (GMT) |
commit | 53d3645f959b95ee1ef2cd7f999ff0cfbce98197 (patch) | |
tree | 815bd92ffeb861c93c4c7341b6f46ebb4dfc810b /Lib | |
parent | 2cbae98ea4cdde9cc67ad308d0def21b49ece5a9 (diff) | |
download | cpython-53d3645f959b95ee1ef2cd7f999ff0cfbce98197.zip cpython-53d3645f959b95ee1ef2cd7f999ff0cfbce98197.tar.gz cpython-53d3645f959b95ee1ef2cd7f999ff0cfbce98197.tar.bz2 |
Issue #13847: Make test_localtime_failure() more robust
Skip the test if we are unable to find an invalid time_t value.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_time.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 292cb85..e3298d5 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -345,16 +345,21 @@ class TimeTestCase(unittest.TestCase): def test_localtime_failure(self): # Issue #13847: check for localtime() failure - invalid_time_t = 2**60 - try: - time.localtime(invalid_time_t) - except ValueError as err: - if str(err) == "timestamp out of range for platform time_t": - self.skipTest("need 64-bit time_t") - else: - raise - except OSError: - pass + invalid_time_t = None + for time_t in (-1, 2**30, 2**33, 2**60): + try: + time.localtime(time_t) + except ValueError as err: + if str(err) == "timestamp out of range for platform time_t": + self.skipTest("need 64-bit time_t") + else: + raise + except OSError: + invalid_time_t = time_t + break + if invalid_time_t is None: + self.skipTest("unable to find an invalid time_t value") + self.assertRaises(OSError, time.localtime, invalid_time_t) self.assertRaises(OSError, time.gmtime, invalid_time_t) self.assertRaises(OSError, time.ctime, invalid_time_t) |