diff options
author | Brett Cannon <brett@python.org> | 2012-03-06 20:33:24 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-03-06 20:33:24 (GMT) |
commit | f67e494ca8dfc72c0f812ed46c6a08ad3b9ddc24 (patch) | |
tree | ceed84488164142e5884411566de19f66702c3e7 /Lib/test/test_time.py | |
parent | 0d4d410b2d6891520b1772a85f5ebdf926a0c77e (diff) | |
parent | 0119e4753eec50f671ee716af202b4a1ca28deef (diff) | |
download | cpython-f67e494ca8dfc72c0f812ed46c6a08ad3b9ddc24.zip cpython-f67e494ca8dfc72c0f812ed46c6a08ad3b9ddc24.tar.gz cpython-f67e494ca8dfc72c0f812ed46c6a08ad3b9ddc24.tar.bz2 |
merge
Diffstat (limited to 'Lib/test/test_time.py')
-rw-r--r-- | Lib/test/test_time.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index a89c511..26492c1 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -497,12 +497,31 @@ class TestStrftime4dyear(_TestStrftimeYear, _Test4dYear): pass +class TestPytime(unittest.TestCase): + def test_timespec(self): + from _testcapi import pytime_object_to_timespec + for obj, timespec in ( + (0, (0, 0)), + (-1, (-1, 0)), + (-1.0, (-1, 0)), + (-1e-9, (-1, 999999999)), + (-1.2, (-2, 800000000)), + (1.123456789, (1, 123456789)), + ): + self.assertEqual(pytime_object_to_timespec(obj), timespec) + + for invalid in (-(2 ** 100), -(2.0 ** 100.0), 2 ** 100, 2.0 ** 100.0): + self.assertRaises(OverflowError, pytime_object_to_timespec, invalid) + + + def test_main(): support.run_unittest( TimeTestCase, TestLocale, TestAsctime4dyear, - TestStrftime4dyear) + TestStrftime4dyear, + TestPytime) if __name__ == "__main__": test_main() |