From a7563c2daccf30c98c661857aff0721dd81dcaea Mon Sep 17 00:00:00 2001 From: Menno Smits Date: Thu, 11 Dec 2014 00:08:07 +1300 Subject: [PATCH] Fixed BODYSTRUCTURE live test The logic for recursing through the BODYSTRUCTURE response wasn't quite right causing failures for Gmail and Fastmail under Python 3. --- imapclient/livetest.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/imapclient/livetest.py b/imapclient/livetest.py index ac97498..0c78a73 100644 --- a/imapclient/livetest.py +++ b/imapclient/livetest.py @@ -749,19 +749,15 @@ def createUidTestClass(conf, use_uid): if multipart is not None: self.assertEqual(actual.is_multipart, multipart) - # BODYSTRUCTURE lengths can various according to the server so - # compare up until what is returned - for e, a in zip(expected, actual): - if have_matching_types(e, a, (list, tuple)): - for expected_and_actual in zip(e, a): - self.check_BODYSTRUCTURE(*expected_and_actual) - else: - if e == (b'charset', b'us-ascii') and a is None: - pass # Some servers (eg. Gmail) don't return a charset when it's us-ascii - else: - a = maybe_lower(a) - e = maybe_lower(e) - self.assertEqual(a, e) + if have_matching_types(expected, actual, (list, tuple)): + # BODYSTRUCTURE lengths can various according to the + # server so compare up until what is returned + for pair in zip(expected, actual): + self.check_BODYSTRUCTURE(*pair) + elif expected == (b'charset', b'us-ascii') and actual is None: + pass # Some servers don't return a charset when it's us-ascii + else: + self.assertEqual(maybe_lower(expected), maybe_lower(actual)) def test_expunge(self): self.client.select_folder(self.base_folder) -- 2.43.0