diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-25 11:06:09 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-25 11:06:09 (GMT) |
commit | e0be4232971edca23438cc3d79761141f2de124f (patch) | |
tree | 7149c8f35615c64e122de1478900f5e8cb516c04 /Lib/test/test_time.py | |
parent | 92b958420e90b5e98c795db75693310cb9317f95 (diff) | |
download | cpython-e0be4232971edca23438cc3d79761141f2de124f.zip cpython-e0be4232971edca23438cc3d79761141f2de124f.tar.gz cpython-e0be4232971edca23438cc3d79761141f2de124f.tar.bz2 |
Close #10278: Add clock_getres(), clock_gettime() and CLOCK_xxx constants to
the time module. time.clock_gettime(time.CLOCK_MONOTONIC) provides a monotonic
clock
Diffstat (limited to 'Lib/test/test_time.py')
-rw-r--r-- | Lib/test/test_time.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 94de098..73c53b3 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -20,6 +20,27 @@ class TimeTestCase(unittest.TestCase): def test_clock(self): time.clock() + @unittest.skipUnless(hasattr(time, 'clock_gettime'), + 'need time.clock_gettime()') + def test_clock_realtime(self): + time.clock_gettime(time.CLOCK_REALTIME) + + @unittest.skipUnless(hasattr(time, 'clock_gettime'), + 'need time.clock_gettime()') + @unittest.skipUnless(hasattr(time, 'CLOCK_MONOTONIC'), + 'need time.CLOCK_MONOTONIC') + def test_clock_monotonic(self): + a = time.clock_gettime(time.CLOCK_MONOTONIC) + b = time.clock_gettime(time.CLOCK_MONOTONIC) + self.assertLessEqual(a, b) + + @unittest.skipUnless(hasattr(time, 'clock_getres'), + 'need time.clock_getres()') + def test_clock_getres(self): + res = time.clock_getres(time.CLOCK_REALTIME) + self.assertGreater(res, 0.0) + self.assertLessEqual(res, 1.0) + def test_conversions(self): self.assertEqual(time.ctime(self.t), time.asctime(time.localtime(self.t))) |