[Python-checkins] python/dist/src/Lib/test test_datetime.py, 1.47,
1.48 test_time.py, 1.16, 1.17
tim_one at users.sourceforge.net
tim_one at users.sourceforge.net
Sat Jun 19 22:50:17 EDT 2004
ot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14933/Lib/test
Modified Files:
test_datetime.py test_time.py
Log Message:
Bug 975996: Add _PyTime_DoubleToTimet to C API
New include file timefuncs.h exports private API function
_PyTime_DoubleToTimet() from timemodule.c. timemodule should export
some other functions too (look for painful bits in datetimemodule.c).
Added insane-argument checking to datetime's assorted fromtimestamp()
and utcfromtimestamp() methods. Added insane-argument tests of these
to test_datetime, and insane-argument tests for ctime(), localtime()
and gmtime() to test_time.
Index: test_datetime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_datetime.py,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** test_datetime.py 7 Jun 2004 23:04:30 -0000 1.47
--- test_datetime.py 20 Jun 2004 02:50:15 -0000 1.48
***************
*** 731,734 ****
--- 731,743 ----
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
***************
*** 1381,1384 ****
--- 1390,1411 ----
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
Index: test_time.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_time.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** test_time.py 2 Mar 2004 04:38:10 -0000 1.16
--- test_time.py 20 Jun 2004 02:50:15 -0000 1.17
***************
*** 177,180 ****
--- 177,188 ----
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():
More information about the Python-checkins
mailing list