Otherwise there will be a UnicodeDecodeError.

Signed-off-by: Dirk Wallenstein <[email protected]>
---

On Thu, Feb 10, 2011 at 01:55:30PM -0200, Guilherme Salgado wrote:
[...]
> It's actually the other way around -- it works if we remove
> the .decode('utf-8') from parse_patch().  With the decode() there the
> tests that try parsing email addresses with non-ascii stuff (e.g.
> patchwork.tests.patchparser.UTF8InlinePatchTest) fail but if we remove
> the .decode('utf-8') they pass.

That can be fixed by manually encoding the content.  The same might be
possible by just omitting the content_encoding argument but the
documentations appears to be not really clear there
(email.mime.text.MIMEText).

 apps/patchwork/tests/patchparser.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/apps/patchwork/tests/patchparser.py 
b/apps/patchwork/tests/patchparser.py
index ff0025a..357ffc1 100644
--- a/apps/patchwork/tests/patchparser.py
+++ b/apps/patchwork/tests/patchparser.py
@@ -80,7 +80,10 @@ class UTF8InlinePatchTest(InlinePatchTest):
 
     def setUp(self):
         self.orig_patch = read_patch(self.patch_filename, self.patch_encoding)
-        email = create_email(self.test_comment + '\n' + self.orig_patch,
+        patch_content = self.test_comment + '\n' + self.orig_patch
+        if isinstance(patch_content, unicode):
+            patch_content = patch_content.encode(self.patch_encoding)
+        email = create_email(patch_content,
                              content_encoding = self.patch_encoding)
         (self.patch, self.comment) = find_content(self.project, email)
 
-- 
1.7.3.2

_______________________________________________
Patchwork mailing list
[email protected]
https://lists.ozlabs.org/listinfo/patchwork

Reply via email to