From 600412e94dced38751df3b465e8391bbd31f52e7 Mon Sep 17 00:00:00 2001 From: Ales Erjavec Date: Thu, 24 May 2018 16:40:46 +0200 Subject: [PATCH] tests: Fix time tracking in process_events Use `perf_counter` (wall time) not `clock` (CPU time). `clock` is deprecated and platform dependent, but mostly does not measure time spent in sleep. --- Orange/widgets/tests/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Orange/widgets/tests/base.py b/Orange/widgets/tests/base.py index 117bd5db5fb..a0be2f1dde7 100644 --- a/Orange/widgets/tests/base.py +++ b/Orange/widgets/tests/base.py @@ -183,7 +183,7 @@ def process_events(self, until: callable=None, timeout=DEFAULT_TIMEOUT): if until is None: until = lambda: True - started = time.clock() + started = time.perf_counter() while True: app.processEvents() try: @@ -192,7 +192,7 @@ def process_events(self, until: callable=None, timeout=DEFAULT_TIMEOUT): return result except Exception: # until can fail with anything; pylint: disable=broad-except pass - if (time.clock() - started) * 1000 > timeout: + if (time.perf_counter() - started) * 1000 > timeout: raise TimeoutError() time.sleep(.05)