diff options
author | Brett Cannon <brett@python.org> | 2012-01-27 00:09:44 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-01-27 00:09:44 (GMT) |
commit | c9f71481d407d08a3c51888f3bfe8575964be7ab (patch) | |
tree | 3889e342a292429b8f7c1b7267f817c80d5170fe /Lib | |
parent | 51d14f8e565cd82a4efb6c18b7fdf29eddcca878 (diff) | |
parent | 53d3645f959b95ee1ef2cd7f999ff0cfbce98197 (diff) | |
download | cpython-c9f71481d407d08a3c51888f3bfe8575964be7ab.zip cpython-c9f71481d407d08a3c51888f3bfe8575964be7ab.tar.gz cpython-c9f71481d407d08a3c51888f3bfe8575964be7ab.tar.bz2 |
Merge
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_time.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 0533895..e3298d5 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -309,7 +309,7 @@ class TimeTestCase(unittest.TestCase): for t in (-2, -1, 0, 1): try: tt = time.localtime(t) - except (OverflowError, ValueError): + except (OverflowError, OSError): pass else: self.assertEqual(time.mktime(tt), t) @@ -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) |