From patchwork Thu Feb 10 18:45:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Wallenstein X-Patchwork-Id: 82651 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 25189B710F for ; Fri, 11 Feb 2011 05:45:10 +1100 (EST) Received: from mailout01.t-online.de (mailout01.t-online.de [194.25.134.80]) by ozlabs.org (Postfix) with ESMTP id 7D20AB70E3 for ; Fri, 11 Feb 2011 05:45:07 +1100 (EST) Received: from fwd24.aul.t-online.de (fwd24.aul.t-online.de ) by mailout01.t-online.de with smtp id 1PnbVl-0007ER-W3; Thu, 10 Feb 2011 19:45:02 +0100 Received: from localhost (E1YMfwZcrhncqA3tQWLyexNRUI69hn5123CFrPWpDgp00yMLMFB-b8Oneu9qqEdwyO@[84.139.64.165]) by fwd24.t-online.de with esmtp id 1PnbVm-1bXyj20; Thu, 10 Feb 2011 19:45:02 +0100 Date: Thu, 10 Feb 2011 19:45:05 +0100 From: Dirk Wallenstein To: Guilherme Salgado Subject: [PATCH] Manually encode utf-8 patch in testcase Message-ID: <20110210184505.GA17251@zap> References: <1265340805-25653-1-git-send-email-madduck@madduck.net> <201012130837.25211.jk@ozlabs.org> <20110113084942.GB12433@zap> <201102101118.39591.jk@ozlabs.org> <20110210053341.GA2195@fishbowl.rw.madduck.net> <1297339366.13357.139.camel@feioso> <20110210144311.GA23673@fishbowl.rw.madduck.net> <1297353330.13357.252.camel@feioso> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1297353330.13357.252.camel@feioso> User-Agent: Mutt/1.5.21 (2010-09-15) X-ID: E1YMfwZcrhncqA3tQWLyexNRUI69hn5123CFrPWpDgp00yMLMFB-b8Oneu9qqEdwyO X-TOI-MSGID: 53500860-a792-4e62-a55f-93b7c8d39dca Cc: "martin f. krafft" , patchwork@lists.ozlabs.org, Jeremy Kerr , Paul Menzel X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Otherwise there will be a UnicodeDecodeError. Signed-off-by: Dirk Wallenstein --- 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)