From 9d2d534cde52d17f44dd05dbfcd47235905d02af Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Thu, 5 Nov 2026 14:59:12 +0100 Subject: [PATCH] Tests: a sleep of Pyjo.Steps on an event loop of libuv, whose timer may be due a millisecond early Co-Authored-By: Claude Opus 5.5 --- t/Pyjo/Steps.py | 4 +++- t/docs/Steps.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/t/Pyjo/Steps.py b/t/Pyjo/Steps.py index db65057b..e79f099e 100644 --- a/t/Pyjo/Steps.py +++ b/t/Pyjo/Steps.py @@ -167,7 +167,9 @@ async def nap(seconds): Pyjo.IOLoop.remove(timer) value, slept = result['value'] is_ok(value, None, 'nothing, non-blocking') - ok(slept >= 0.2, 'slept, non-blocking') + # A timer of an event loop on libuv, as the ones of uvloop and gevent, counts whole milliseconds of a clock that + # libuv rounds down, so it may be due up to a millisecond early by time.monotonic + ok(slept >= 0.19, 'slept, non-blocking') ok(len(ticks) >= 3, 'other events meanwhile') async def retried(): diff --git a/t/docs/Steps.py b/t/docs/Steps.py index 38aa70ad..7dd29019 100644 --- a/t/docs/Steps.py +++ b/t/docs/Steps.py @@ -117,7 +117,9 @@ async def sleeps(): ok(Steps(sleeps()).run(ua) >= 0.6, 'sleeps, blocking') result = [] Pyjo.Steps.new(sleeps()).run_p(ua).then(result.append).wait() - ok(result[0] >= 0.6, 'sleeps, non-blocking') + # A timer of an event loop on libuv, as the ones of uvloop and gevent, counts whole milliseconds of a clock that + # libuv rounds down, so each one may be due up to a millisecond early by time.monotonic + ok(result[0] >= 0.59, 'sleeps, non-blocking') with subtest('Steps'):