"round" may bump 1 second to 2 if sleep takes more than 1.49 sec
Use less than 2 as a way to account for test on slower systems. This is a follow up to: https://review.opendev.org/#/c/691883/ Trivial-Fix Change-Id: Ia313b9c4028f0242cb0da8764b9921c5c30c465a Fixes-Bug: #1891517
This commit is contained in:
parent
54da471a00
commit
6a9fce39d6
@ -542,13 +542,13 @@ class TimerTestCase(base.BaseTestCase):
|
||||
def test__getattr(self):
|
||||
with utils.Timer() as timer:
|
||||
time.sleep(1)
|
||||
self.assertEqual(1, round(timer.total_seconds()))
|
||||
self.assertLess(timer.total_seconds(), 2)
|
||||
self.assertEqual(1, timer.delta.seconds)
|
||||
|
||||
def test__enter_with_timeout(self):
|
||||
with utils.Timer(timeout=10) as timer:
|
||||
time.sleep(1)
|
||||
self.assertEqual(1, round(timer.total_seconds()))
|
||||
self.assertLess(timer.total_seconds(), 2)
|
||||
|
||||
def test__enter_with_timeout_exception(self):
|
||||
msg = r'Timer timeout expired after 1 second\(s\).'
|
||||
|
Loading…
x
Reference in New Issue
Block a user