From 6325a35b5b0e5a8adcd877a29963851fd4b28e80 Mon Sep 17 00:00:00 2001 From: link2xt Date: Wed, 28 Jan 2026 23:09:23 +0000 Subject: [PATCH] test: make test_dont_move_sync_msgs less flaky --- deltachat-rpc-client/tests/test_something.py | 21 +++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index ddac6b39d..f3f33cb15 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -5,6 +5,7 @@ import logging import os import socket import subprocess +import time from unittest.mock import MagicMock import pytest @@ -387,19 +388,29 @@ def test_dont_move_sync_msgs(acfactory, direct_imap): ac1.set_config("bcc_self", "1") ac1.set_config("fix_is_chatmail", "1") ac1.add_or_update_transport({"addr": addr, "password": password}) - ac1.bring_online() + ac1.start_io() ac1_direct_imap = direct_imap(ac1) - ac1_direct_imap.select_folder("Inbox") # Sync messages may also be sent during configuration. - inbox_msg_cnt = len(ac1_direct_imap.get_all_messages()) + ac1.wait_for_event(EventType.MSG_DELIVERED) + ac1_direct_imap.select_folder("Inbox") + while True: + if len(ac1_direct_imap.get_all_messages()) == 1: + break + time.sleep(1) ac1.set_config("displayname", "Alice") ac1.wait_for_event(EventType.MSG_DELIVERED) ac1.set_config("displayname", "Bob") ac1.wait_for_event(EventType.MSG_DELIVERED) - ac1_direct_imap.select_folder("Inbox") - assert len(ac1_direct_imap.get_all_messages()) == inbox_msg_cnt + 2 + + # Message may not be delivered to IMAP immediately + # after sending over SMTP, + # retry until they are delivered to IMAP. + while True: + if len(ac1_direct_imap.get_all_messages()) == 3: + break + time.sleep(1) def test_reaction_seen_on_another_dev(acfactory) -> None: