summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2016-09-07 17:39:36 (GMT)
committerR David Murray <rdmurray@bitdance.com>2016-09-07 17:39:36 (GMT)
commitc2e2473bc210ff83c2cbc73c4b916893f773b480 (patch)
tree7d773f8dc337bc685924c6a99c1703692ce47f11 /Lib/test
parent48c88307d87ae0704885b9b5c692ded861077a71 (diff)
downloadcpython-c2e2473bc210ff83c2cbc73c4b916893f773b480.zip
cpython-c2e2473bc210ff83c2cbc73c4b916893f773b480.tar.gz
cpython-c2e2473bc210ff83c2cbc73c4b916893f773b480.tar.bz2
27988: Make sure iter_attachments does not mutate the payload list.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_email/test_message.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_message.py b/Lib/test/test_email/test_message.py
index d78049e..4345162 100644
--- a/Lib/test/test_email/test_message.py
+++ b/Lib/test/test_email/test_message.py
@@ -732,6 +732,16 @@ class TestEmailMessageBase:
m.set_param('filename', 'abc.png', 'Content-Disposition')
self.assertTrue(m.is_attachment())
+ def test_iter_attachments_mutation(self):
+ # We had a bug where iter_attachments was mutating the list.
+ m = self._make_message()
+ m.set_content('arbitrary text as main part')
+ m.add_related('more text as a related part')
+ m.add_related('yet more text as a second "attachment"')
+ orig = m.get_payload().copy()
+ self.assertEqual(len(list(m.iter_attachments())), 2)
+ self.assertEqual(m.get_payload(), orig)
+
class TestEmailMessage(TestEmailMessageBase, TestEmailBase):
message = EmailMessage