From d39ed9d0f16bc04cd7f81f38c742e91fd0abdd56 Mon Sep 17 00:00:00 2001 From: link2xt Date: Wed, 12 Nov 2025 00:01:48 +0000 Subject: [PATCH] test: fix flaky test_send_receive_locations --- python/tests/test_1_online.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index 7c235960e..8718fe283 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -1509,9 +1509,15 @@ def test_send_receive_locations(acfactory, lp): assert locations[0].latitude == 2.0 assert locations[0].longitude == 3.0 assert locations[0].accuracy == 0.5 - assert locations[0].timestamp > now assert locations[0].marker is None + # Make sure the timestamp is not in the past. + # Note that location timestamp has only 1 second precision, + # while `now` has a fractional part, so we have to truncate it + # first, otherwise `now` may appear to be in the future + # even though it is the same second. + assert int(locations[0].timestamp.timestamp()) >= int(now.timestamp()) + contact = ac2.create_contact(ac1) locations2 = chat2.get_locations(contact=contact) assert len(locations2) == 1