(original) (raw)

changeset: 74534:8502a9236c2e user: Victor Stinner victor.stinner@haypocalc.com date: Fri Jan 20 02:24:18 2012 +0100 files: Lib/test/test_time.py description: Issue #10278: Be more explicit in tests than wallclock() is monotonic (cannot go backward) diff -r 5c33ebb50702 -r 8502a9236c2e Lib/test/test_time.py --- a/Lib/test/test_time.py Thu Jan 19 20:04:28 2012 -0500 +++ b/Lib/test/test_time.py Fri Jan 20 02:24:18 2012 +0100 @@ -332,11 +332,16 @@ self.assertEqual(time.strftime('%Z', tt), tzname) def test_wallclock(self): - t0 = time.wallclock() - time.sleep(0.1) + t1 = time.wallclock() + t2 = time.wallclock() + self.assertGreater(t2, t1) + t1 = time.wallclock() - t = t1 - t0 - self.assertAlmostEqual(t, 0.1, delta=0.2) + 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): /victor.stinner@haypocalc.com