summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2014-03-06 16:44:17 (GMT)
committerR David Murray <rdmurray@bitdance.com>2014-03-06 16:44:17 (GMT)
commit5dda12491e3e2233b63737a1c5f6066f54f6deb5 (patch)
treeadb09127fa2582cf98e47f3e643b7ba7f8a36001 /Lib/test/test_email
parent733e50ad9ee2885323c39080b42716fa5d1fd8c1 (diff)
downloadcpython-5dda12491e3e2233b63737a1c5f6066f54f6deb5.zip
cpython-5dda12491e3e2233b63737a1c5f6066f54f6deb5.tar.gz
cpython-5dda12491e3e2233b63737a1c5f6066f54f6deb5.tar.bz2
#11558: Better message if attach called on non-multipart.
Original patch by Varun Sharma.
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r--Lib/test/test_email/test_email.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py
index 26ed96c..2f89a10 100644
--- a/Lib/test/test_email/test_email.py
+++ b/Lib/test/test_email/test_email.py
@@ -124,6 +124,14 @@ class TestMessageAPI(TestEmailBase):
msg.set_payload([])
self.assertEqual(msg.get_payload(), [])
+ def test_attach_when_payload_is_string(self):
+ msg = Message()
+ msg['Content-Type'] = 'multipart/mixed'
+ msg.set_payload('string payload')
+ sub_msg = MIMEMessage(Message())
+ self.assertRaisesRegex(TypeError, "[Aa]ttach.*non-multipart",
+ msg.attach, sub_msg)
+
def test_get_charsets(self):
eq = self.assertEqual