summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_datetime.py27
-rw-r--r--Lib/test/test_time.py8
2 files changed, 35 insertions, 0 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index f7fec57..2a6aca2 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -730,6 +730,15 @@ class TestDate(HarmlessMixedComparison):
self.assertEqual(d.month, month)
self.assertEqual(d.day, day)
+ def test_insane_fromtimestamp(self):
+ # It's possible that some platform maps time_t to double,
+ # and that this test will fail there. This test should
+ # exempt such platforms (provided they return reasonable
+ # results!).
+ for insane in -1e200, 1e200:
+ self.assertRaises(ValueError, self.theclass.fromtimestamp,
+ insane)
+
def test_today(self):
import time
@@ -1380,6 +1389,24 @@ class TestDateTime(TestDate):
got = self.theclass.utcfromtimestamp(ts)
self.verify_field_equality(expected, got)
+ def test_insane_fromtimestamp(self):
+ # It's possible that some platform maps time_t to double,
+ # and that this test will fail there. This test should
+ # exempt such platforms (provided they return reasonable
+ # results!).
+ for insane in -1e200, 1e200:
+ self.assertRaises(ValueError, self.theclass.fromtimestamp,
+ insane)
+
+ def test_insane_utcfromtimestamp(self):
+ # It's possible that some platform maps time_t to double,
+ # and that this test will fail there. This test should
+ # exempt such platforms (provided they return reasonable
+ # results!).
+ for insane in -1e200, 1e200:
+ self.assertRaises(ValueError, self.theclass.utcfromtimestamp,
+ insane)
+
def test_utcnow(self):
import time
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index 9e16d0b..64f1f01 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -176,6 +176,14 @@ class TimeTestCase(unittest.TestCase):
del environ['TZ']
time.tzset()
+ def test_insane_timestamps(self):
+ # It's possible that some platform maps time_t to double,
+ # and that this test will fail there. This test should
+ # exempt such platforms (provided they return reasonable
+ # results!).
+ for func in time.ctime, time.gmtime, time.localtime:
+ for unreasonable in -1e200, 1e200:
+ self.assertRaises(ValueError, func, unreasonable)
def test_main():
test_support.run_unittest(TimeTestCase)