[Python-checkins] cpython: Issue #13847: Make test_localtime_failure() more robust
victor.stinner
python-checkins at python.org
Fri Jan 27 01:03:28 CET 2012
http://hg.python.org/cpython/rev/856f0864437a
changeset: 74642:856f0864437a
user: Victor Stinner <victor.stinner at haypocalc.com>
date: Fri Jan 27 01:03:25 2012 +0100
summary:
Issue #13847: Make test_localtime_failure() more robust
Skip the test if we are unable to find an invalid time_t value.
files:
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
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -345,16 +345,21 @@
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)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list