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/89d63f768f54f61056d0d4cec37800ac4dd9a0bc?hp=9e8410fe71ea97c659ff61647598495a5a0e03ee 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(