From 35eddd53f9469cf8b1a220d5bc3e9d9776bc4094 Mon Sep 17 00:00:00 2001 From: Flavio Fernandes Date: Thu, 13 Aug 2020 10:56:23 -0400 Subject: [PATCH] "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 (cherry picked from commit 6a9fce39d6cf0051c6ea0f3bf5d57b9a7a03c3b8) --- neutron/tests/unit/common/test_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neutron/tests/unit/common/test_utils.py b/neutron/tests/unit/common/test_utils.py index 80461253980..c291ee513b1 100644 --- a/neutron/tests/unit/common/test_utils.py +++ b/neutron/tests/unit/common/test_utils.py @@ -544,13 +544,13 @@ class TimerTestCase(base.BaseTestCase): def test__getattr(self): with utils.Timer() as timer: time.sleep(1) - self.assertEqual(1, round(timer.total_seconds(), 0)) + 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(), 0)) + self.assertLess(timer.total_seconds(), 2) def test__enter_with_timeout_exception(self): msg = r'Timer timeout expired after 1 second\(s\).'