From 3d86cb59537944fe3596b46d40ebc66d33c49b27 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 7 Nov 2025 03:55:57 +0000 Subject: [PATCH] test: remove ThreadPoolExecutor from test_wait_next_messages --- .../src/deltachat_rpc_client/account.py | 3 ++- deltachat-rpc-client/tests/test_something.py | 23 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/deltachat-rpc-client/src/deltachat_rpc_client/account.py b/deltachat-rpc-client/src/deltachat_rpc_client/account.py index 2e6941944..70b823ca6 100644 --- a/deltachat-rpc-client/src/deltachat_rpc_client/account.py +++ b/deltachat-rpc-client/src/deltachat_rpc_client/account.py @@ -399,9 +399,10 @@ class Account: next_msg_ids = self._rpc.get_next_msgs(self.id) return [Message(self, msg_id) for msg_id in next_msg_ids] + @futuremethod def wait_next_messages(self) -> list[Message]: """Wait for new messages and return a list of them.""" - next_msg_ids = self._rpc.wait_next_msgs(self.id) + next_msg_ids = yield self._rpc.wait_next_msgs.future(self.id) return [Message(self, msg_id) for msg_id in next_msg_ids] def wait_for_incoming_msg_event(self): diff --git a/deltachat-rpc-client/tests/test_something.py b/deltachat-rpc-client/tests/test_something.py index 70b2c5803..f0c9879d4 100644 --- a/deltachat-rpc-client/tests/test_something.py +++ b/deltachat-rpc-client/tests/test_something.py @@ -484,22 +484,21 @@ def test_wait_next_messages(acfactory) -> None: # There are no old messages and the call returns immediately. assert not bot.wait_next_messages() - with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: - # Bot starts waiting for messages. - next_messages_task = executor.submit(bot.wait_next_messages) + # Bot starts waiting for messages. + next_messages_task = bot.wait_next_messages.future() - alice_contact_bot = alice.create_contact(bot, "Bot") - alice_chat_bot = alice_contact_bot.create_chat() - alice_chat_bot.send_text("Hello!") + alice_contact_bot = alice.create_contact(bot, "Bot") + alice_chat_bot = alice_contact_bot.create_chat() + alice_chat_bot.send_text("Hello!") - next_messages = next_messages_task.result() + next_messages = next_messages_task() - if len(next_messages) == E2EE_INFO_MSGS: - next_messages += bot.wait_next_messages() + if len(next_messages) == E2EE_INFO_MSGS: + next_messages += bot.wait_next_messages() - assert len(next_messages) == 1 + E2EE_INFO_MSGS - snapshot = next_messages[0 + E2EE_INFO_MSGS].get_snapshot() - assert snapshot.text == "Hello!" + assert len(next_messages) == 1 + E2EE_INFO_MSGS + snapshot = next_messages[0 + E2EE_INFO_MSGS].get_snapshot() + assert snapshot.text == "Hello!" def test_import_export_backup(acfactory, tmp_path) -> None: