From 77f17c766d0c50c655b8f158844a1a9e8d61be38 Mon Sep 17 00:00:00 2001 From: Dmitry Erlikh Date: Sat, 24 Oct 2020 18:24:59 +0200 Subject: [PATCH] Fix flaky test_when_timeout_smaller_second (#5117) * Fix flaky test_when_timeout_smaller_second * Use absolute tolerance --- CHANGES/5116.bugfix | 1 + tests/test_helpers.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 CHANGES/5116.bugfix diff --git a/CHANGES/5116.bugfix b/CHANGES/5116.bugfix new file mode 100644 index 00000000000..253fd8177b0 --- /dev/null +++ b/CHANGES/5116.bugfix @@ -0,0 +1 @@ +Fix flaky test_when_timeout_smaller_second diff --git a/tests/test_helpers.py b/tests/test_helpers.py index d4905ca7c7b..8581c221e55 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -5,7 +5,7 @@ import platform import sys import tempfile -from math import modf +from math import isclose, modf from unittest import mock import pytest @@ -337,7 +337,7 @@ def test_when_timeout_smaller_second(loop) -> None: handle.close() assert isinstance(when, float) - assert abs(when - timer) < 0.01 + assert isclose(when - timer, 0, abs_tol=0.001) def test_timeout_handle_cb_exc(loop) -> None: