From e8cdc4e45c014d5b32e85a005ba2bbaad55c2077 Mon Sep 17 00:00:00 2001 From: "r.inyakin" Date: Mon, 31 Aug 2026 16:46:21 +0300 Subject: [PATCH] test: fix ping test on windows The `ping` method measures the duration using the `time.perf_counter()` function. It has the same resolution as `time.time()` on Unix, but provides higher resolution on Windows. Closes #214 --- CHANGELOG.md | 3 +++ tarantool/connection.py | 4 ++-- test/suites/test_dml.py | 3 --- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1d5d874..2b1128e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed ### Fixed +- Measure `ping()` response time with `time.perf_counter()` instead of + `time.time()`. On Windows with Python 3.12 and older the latter has a + resolution of 15.6 ms, so `ping()` could return `0.0` (PR #350). ## [1.3.0] - 2026-08-17 diff --git a/tarantool/connection.py b/tarantool/connection.py index 2572ea47..d8a8ec8a 100644 --- a/tarantool/connection.py +++ b/tarantool/connection.py @@ -1910,9 +1910,9 @@ def ping(self, notime=False): """ request = RequestPing(self) - start_time = time.time() + start_time = time.perf_counter() self._send_request(request) - finish_time = time.time() + finish_time = time.perf_counter() if notime: return "Success" diff --git a/test/suites/test_dml.py b/test/suites/test_dml.py index 26539eec..a252b3ee 100644 --- a/test/suites/test_dml.py +++ b/test/suites/test_dml.py @@ -171,9 +171,6 @@ def test_05_ping(self): # Simple ping test # * No exceptions are raised # * Ping time > 0 - if sys.platform.startswith("win"): - self.skipTest("Windows clock precision causes test to fail sometimes, see #214") - self.assertTrue(self.con.ping() > 0) self.assertEqual(self.con.ping(notime=True), "Success")