diff options
Diffstat (limited to 'tests/misc/cexample_class.py')
-rw-r--r-- | tests/misc/cexample_class.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/misc/cexample_class.py b/tests/misc/cexample_class.py index bdeb9a8cb..6b8718ad8 100644 --- a/tests/misc/cexample_class.py +++ b/tests/misc/cexample_class.py @@ -7,14 +7,18 @@ except ImportError: print("SKIP") raise SystemExit -t = cexample.Timer() -print(t) -print(t.time() <= 1) +SLEEP_MS = 100 +TOLERANCE_MS = 20 + +timer = cexample.Timer() + +t_start = timer.time() time.sleep_ms(100) -elapsed = t.time() +t_end = timer.time() -if not (99 <= elapsed <= 110): - print("Elapsed time should be approx. 100ms but it is", elapsed) +print(timer) +print(0 <= t_start <= TOLERANCE_MS) +print(SLEEP_MS - TOLERANCE_MS <= t_end <= SLEEP_MS + TOLERANCE_MS) |