]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #10278: Be more explicit in tests than wallclock() is monotonic (cannot
authorVictor Stinner <victor.stinner@haypocalc.com>
Fri, 20 Jan 2012 01:24:18 +0000 (02:24 +0100)
committerVictor Stinner <victor.stinner@haypocalc.com>
Fri, 20 Jan 2012 01:24:18 +0000 (02:24 +0100)
go backward)

Lib/test/test_time.py

index 1597ac1ace52157dd544f66c16c1d8f3e9ab60ea..d34b870f7322811f5732d2423be6a1ebd550db68 100644 (file)
@@ -332,11 +332,16 @@ class TimeTestCase(unittest.TestCase):
         self.assertEqual(time.strftime('%Z', tt), tzname)
 
     def test_wallclock(self):
-        t0 = time.wallclock()
-        time.sleep(0.1)
         t1 = time.wallclock()
-        t = t1 - t0
-        self.assertAlmostEqual(t, 0.1, delta=0.2)
+        t2 = time.wallclock()
+        self.assertGreater(t2, t1)
+
+        t1 = time.wallclock()
+        time.sleep(0.1)
+        t2 = time.wallclock()
+        self.assertGreater(t2, t1)
+        dt = t2 - t1
+        self.assertAlmostEqual(dt, 0.1, delta=0.2)
 
 
 class TestLocale(unittest.TestCase):