Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2dd254d

Browse files
author
Victor Stinner
committed
Issue #10278: Be more explicit in tests than wallclock() is monotonic (cannot
go backward)
1 parent d25cfe6 commit 2dd254d

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

Lib/test/test_time.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,16 @@ def test_mktime_error(self):
332332
self.assertEqual(time.strftime('%Z', tt), tzname)
333333

334334
def test_wallclock(self):
335-
t0 = time.wallclock()
336-
time.sleep(0.1)
337335
t1 = time.wallclock()
338-
t = t1 - t0
339-
self.assertAlmostEqual(t, 0.1, delta=0.2)
336+
t2 = time.wallclock()
337+
self.assertGreater(t2, t1)
338+
339+
t1 = time.wallclock()
340+
time.sleep(0.1)
341+
t2 = time.wallclock()
342+
self.assertGreater(t2, t1)
343+
dt = t2 - t1
344+
self.assertAlmostEqual(dt, 0.1, delta=0.2)
340345

341346

342347
class TestLocale(unittest.TestCase):

0 commit comments

Comments
 (0)