summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_time.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-03-14 23:58:32 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2012-03-14 23:58:32 (GMT)
commitec919cc74d48cac88ff15ee31084f2eab9add417 (patch)
tree16cc80d15a0512b02fad229781b901823987e924 /Lib/test/test_time.py
parent5e5451940c0e5b820569e842b7cd2cc73add7db3 (diff)
downloadcpython-ec919cc74d48cac88ff15ee31084f2eab9add417.zip
cpython-ec919cc74d48cac88ff15ee31084f2eab9add417.tar.gz
cpython-ec919cc74d48cac88ff15ee31084f2eab9add417.tar.bz2
Issue #10278: Drop time.monotonic() function, rename time.wallclock() to time.steady()
* On Mac OS X, time.steady() now uses mach_absolute_time(), a monotonic clock * Optimistic change: bet that CLOCK_MONOTONIC and CLOCK_REALTIME are available when clock_gettime() is available * Rewrite time.steady() documentation
Diffstat (limited to 'Lib/test/test_time.py')
-rw-r--r--Lib/test/test_time.py25
1 files changed, 3 insertions, 22 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index 1fc46aa..2baf066 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -331,29 +331,10 @@ class TimeTestCase(unittest.TestCase):
pass
self.assertEqual(time.strftime('%Z', tt), tzname)
- @unittest.skipUnless(hasattr(time, 'monotonic'),
- 'need time.monotonic()')
- def test_monotonic(self):
- t1 = time.monotonic()
- t2 = time.monotonic()
- self.assertGreaterEqual(t2, t1)
-
- t1 = time.monotonic()
+ def test_steady(self):
+ t1 = time.steady()
time.sleep(0.1)
- t2 = time.monotonic()
- dt = t2 - t1
- self.assertGreater(t2, t1)
- self.assertAlmostEqual(dt, 0.1, delta=0.2)
-
- def test_wallclock(self):
- t1 = time.wallclock()
- t2 = time.wallclock()
- # may fail if the system clock was changed
- self.assertGreaterEqual(t2, t1)
-
- t1 = time.wallclock()
- time.sleep(0.1)
- t2 = time.wallclock()
+ t2 = time.steady()
dt = t2 - t1
# may fail if the system clock was changed
self.assertGreater(t2, t1)