Skip to content

Commit d39ed9d

Browse files
committed
test: fix flaky test_send_receive_locations
1 parent c499dab commit d39ed9d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

python/tests/test_1_online.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,9 +1509,15 @@ def test_send_receive_locations(acfactory, lp):
15091509
assert locations[0].latitude == 2.0
15101510
assert locations[0].longitude == 3.0
15111511
assert locations[0].accuracy == 0.5
1512-
assert locations[0].timestamp > now
15131512
assert locations[0].marker is None
15141513

1514+
# Make sure the timestamp is not in the past.
1515+
# Note that location timestamp has only 1 second precision,
1516+
# while `now` has a fractional part, so we have to truncate it
1517+
# first, otherwise `now` may appear to be in the future
1518+
# even though it is the same second.
1519+
assert int(locations[0].timestamp.timestamp()) >= int(now.timestamp())
1520+
15151521
contact = ac2.create_contact(ac1)
15161522
locations2 = chat2.get_locations(contact=contact)
15171523
assert len(locations2) == 1

0 commit comments

Comments
 (0)