From 4f8e7e0166bdab98f943d389fb28f88019ca8daa Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 8 Aug 2020 23:03:59 +0300 Subject: [PATCH] python: fix more flaky tests This change fixes test_immediate_autodelete and maybe other tests using DirectImap.get_all_messages(). --- python/src/deltachat/direct_imap.py | 9 +++++++++ python/tests/test_account.py | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/python/src/deltachat/direct_imap.py b/python/src/deltachat/direct_imap.py index 2d86b9754..c4c118486 100644 --- a/python/src/deltachat/direct_imap.py +++ b/python/src/deltachat/direct_imap.py @@ -108,6 +108,15 @@ class DirectImap: def get_all_messages(self): assert not self._idling + + # Flush unsolicited responses. IMAPClient has problems + # dealing with them: https://github.com/mjs/imapclient/issues/334 + # When this NOOP was introduced, next FETCH returned empty + # result instead of a single message, even though IMAP server + # can only return more untagged responses than required, not + # less. + self.conn.noop() + return self.conn.fetch(ALL, [FLAGS]) def get_unread_messages(self): diff --git a/python/tests/test_account.py b/python/tests/test_account.py index a2a7d8980..22b7e3539 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -1688,14 +1688,6 @@ class TestOnlineAccount: lp.sec("imap2: test that only one message is left") imap2 = ac2.direct_imap - # Flush unsolicited responses. IMAPClient has problems - # dealing with them: https://github.com/mjs/imapclient/issues/334 - # When this NOOP was introduced, next FETCH returned empty - # result instead of a single message, even though IMAP server - # can only return more untagged responses than required, not - # less. - imap2.conn.noop() - assert len(imap2.get_all_messages()) == 1