]> git.ozlabs.org Git - patchwork/commitdiff
tests/utils: Specify content encoding on MIMEText() construction
authorJeremy Kerr <jk@ozlabs.org>
Tue, 10 Aug 2010 03:41:58 +0000 (11:41 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 10 Aug 2010 03:49:36 +0000 (11:49 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
apps/patchwork/tests/utils.py

index 7166ed27ccdc0fdb7bdb11fce584fab3e2f0c05d..02e0523bc9dfa4147eab1b4c4a403c85657f22e0 100644 (file)
@@ -92,17 +92,16 @@ def create_email(content, subject = None, sender = None, multipart = False,
         sender = defaults.sender
     if project is None:
         project = defaults.project
+    if content_encoding is None:
+        content_encoding = 'us-ascii'
 
     if multipart:
         msg = MIMEMultipart()
-        body = MIMEText(content, _subtype = 'plain')
-        if content_encoding is not None:
-            body.set_charset(content_encoding)
+        body = MIMEText(content, _subtype = 'plain',
+                        _charset = content_encoding)
         msg.attach(body)
     else:
-        msg = MIMEText(content)
-        if content_encoding is not None:
-            msg.set_charset(content_encoding)
+        msg = MIMEText(content, _charset = content_encoding)
 
     msg['Subject'] = subject
     msg['From'] = sender