[New-bugs-announce] [issue35513] Lib/test/lock_tests.py should not use time.time(), but time.monotonic()

STINNER Victor report at bugs.python.org
Sun Dec 16 17:05:49 EST 2018


New submission from STINNER Victor <vstinner at redhat.com>:

https://buildbot.python.org/all/#/builders/145/builds/956

Unhandled exception in thread started by <function Bunch.__init__.<locals>.task at 0x111775cb0>
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/lock_tests.py", line 41, in task
    f()
  File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/lock_tests.py", line 591, in f
    self.assertTimeout(dt, 0.1)
  File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/lock_tests.py", line 80, in assertTimeout
    self.assertGreaterEqual(actual, expected * 0.6)
  File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/case.py", line 1283, in assertGreaterEqual
    self.fail(self._formatMessage(msg, standardMsg))
  File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/case.py", line 719, in fail
    raise self.failureException(msg)
AssertionError: -0.24049997329711914 not greater than or equal to 0.06
test_waitfor_timeout (test.test_threading.ConditionTests) ... FAIL

test_waitfor_timeout():

                ...
                dt = time.time()
                result = cond.wait_for(lambda : state==4, timeout=0.1)
                dt = time.time() - dt
                self.assertFalse(result)
                self.assertTimeout(dt, 0.1)
                ...

with:

    def assertTimeout(self, actual, expected):
        ...
        self.assertGreaterEqual(actual, expected * 0.6)
        ...

It seems like time.time() gone backward on the buildbot. The test must use time.monotonic() to measure time difference.

Attached PR fix the issue.

----------
components: Tests
messages: 331939
nosy: pablogsal, vstinner
priority: normal
severity: normal
status: open
title: Lib/test/lock_tests.py should not use time.time(), but time.monotonic()
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35513>
_______________________________________


More information about the New-bugs-announce mailing list