summaryrefslogtreecommitdiff
path: root/tests/mail
diff options
context:
space:
mode:
authorIgor Tokarev <TigorC@gmail.com>2017-08-28 09:28:18 +0500
committerTim Graham <timograham@gmail.com>2017-09-04 08:46:11 -0400
commitaf35c69a3c595ff77188ff0d7dac6ab747484ac3 (patch)
tree49cfc11a8dd776bbd36e87992271bba5cda5b0c8 /tests/mail
parentd81c86d32c6b716e49288c22c80ceb6ee924531f (diff)
downloaddjango-af35c69a3c595ff77188ff0d7dac6ab747484ac3.tar.gz
Fixed #26344 -- Made EmailMessage include alternatives when the body is empty and it has attachments.
Diffstat (limited to 'tests/mail')
-rw-r--r--tests/mail/tests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index e1a7feb1f9..b759484e04 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -319,6 +319,17 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
self.assertEqual(msg.message()['To'], '=?iso-8859-1?q?S=FCrname=2C_Firstname?= <to@example.com>')
self.assertEqual(msg.message()['Subject'], '=?iso-8859-1?q?Message_from_Firstname_S=FCrname?=')
+ def test_safe_mime_multipart_with_attachments(self):
+ """
+ EmailMultiAlternatives includes alternatives if the body is empty and
+ it has attachments.
+ """
+ msg = EmailMultiAlternatives(body='')
+ html_content = '<p>This is <strong>html</strong></p>'
+ msg.attach_alternative(html_content, 'text/html')
+ msg.attach('example.txt', 'Text file content', 'text/plain')
+ self.assertIn(html_content, msg.message().as_string())
+
def test_encoding(self):
"""
Regression for #12791 - Encode body correctly with other encodings