From: martin f. krafft Date: Thu, 24 Aug 2023 13:27:26 +0000 (+1200) Subject: buildmimetree.py: list only becomes mp/mixed if len>1 X-Git-Url: https://git.madduck.net/etc/neomutt.git/commitdiff_plain/aab847e0ae71667bc2397830c407ef392ae8c459?ds=inline buildmimetree.py: list only becomes mp/mixed if len>1 --- diff --git a/.config/neomutt/buildmimetree.py b/.config/neomutt/buildmimetree.py index 4ab7a54..779f60b 100755 --- a/.config/neomutt/buildmimetree.py +++ b/.config/neomutt/buildmimetree.py @@ -350,9 +350,11 @@ class MIMETreeDFWalker: Recursive function to implement a depth-dirst walk of the MIME-tree rooted at `root`. """ - if isinstance(root, list): - root = Multipart("mixed", children=root) + if len(root) > 1: + root = Multipart("mixed", children=root) + else: + root = root[0] self._walk( root, @@ -723,14 +725,17 @@ try: assert items[4][0].subtype == "relative" assert items[4][1] == 0 - def test_MIMETreeDFWalker_list_to_mixed(self, basic_mime_tree): + def test_MIMETreeDFWalker_list_to_mixed(self, const1): mimetree = MIMETreeDFWalker() items = [] def visitor_fn(item, stack, debugprint): items.append(item) - mimetree.walk([basic_mime_tree], visitor_fn=visitor_fn) + p = Part("text", "plain", const1) + mimetree.walk([p], visitor_fn=visitor_fn) + assert items[-1].subtype == "plain" + mimetree.walk([p, p], visitor_fn=visitor_fn) assert items[-1].subtype == "mixed" def test_MIMETreeDFWalker_visitor_in_constructor(