1 Return-Path: <tomi.ollila@iki.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 20623431FB6
\r
6 for <notmuch@notmuchmail.org>; Thu, 6 Dec 2012 13:15:19 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 5epmUD7jef4R for <notmuch@notmuchmail.org>;
\r
16 Thu, 6 Dec 2012 13:15:18 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 2C43A431FAE
\r
19 for <notmuch@notmuchmail.org>; Thu, 6 Dec 2012 13:15:18 -0800 (PST)
\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])
\r
21 by guru.guru-group.fi (Postfix) with ESMTP id 625ED100045;
\r
22 Thu, 6 Dec 2012 23:15:13 +0200 (EET)
\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
24 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org
\r
25 Subject: Re: [PATCH] test: Fix UTF-8 JSON tests in Python 3
\r
26 In-Reply-To: <1354634654-9564-1-git-send-email-amdragon@mit.edu>
\r
27 References: <87d2yp27zu.fsf@nexoid.at>
\r
28 <1354634654-9564-1-git-send-email-amdragon@mit.edu>
\r
29 User-Agent: Notmuch/0.14+116~g29fcdb5 (http://notmuchmail.org) Emacs/24.2.1
\r
30 (x86_64-unknown-linux-gnu)
\r
31 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
32 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
33 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
34 Date: Thu, 06 Dec 2012 23:15:13 +0200
\r
35 Message-ID: <m2vcceq3vi.fsf@guru.guru-group.fi>
\r
37 Content-Type: text/plain
\r
38 X-BeenThere: notmuch@notmuchmail.org
\r
39 X-Mailman-Version: 2.1.13
\r
41 List-Id: "Use and development of the notmuch mail system."
\r
42 <notmuch.notmuchmail.org>
\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
46 List-Post: <mailto:notmuch@notmuchmail.org>
\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
50 X-List-Received-Date: Thu, 06 Dec 2012 21:15:19 -0000
\r
52 On Tue, Dec 04 2012, Austin Clements <amdragon@MIT.EDU> wrote:
\r
54 > test_expect_equal_json uses json.tool from the system Python. While
\r
55 > Python 2 wasn't picky about the encoding of stdin, Python 3 decodes
\r
56 > stdin strictly according to the environment. Since we set LC_ALL=C
\r
57 > for the tests, Python 3's json.tool was assuming stdin would be in
\r
58 > ASCII and aborting when it couldn't decode the UTF-8 characters from
\r
59 > some of the JSON tests. This patch sets the PYTHONIOENCODING
\r
60 > environment variable to utf-8 when invoking json.tool to override
\r
61 > Python's default encoding choice.
\r
68 > test/test-lib.sh | 9 +++++++--
\r
69 > 1 file changed, 7 insertions(+), 2 deletions(-)
\r
71 > diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
72 > index f169785..9487526 100644
\r
73 > --- a/test/test-lib.sh
\r
74 > +++ b/test/test-lib.sh
\r
75 > @@ -534,8 +534,13 @@ test_expect_equal_file ()
\r
76 > # canonicalized before diff'ing. If an argument cannot be parsed, it
\r
77 > # is used unchanged so that there's something to diff against.
\r
78 > test_expect_equal_json () {
\r
79 > - output=$(echo "$1" | python -mjson.tool || echo "$1")
\r
80 > - expected=$(echo "$2" | python -mjson.tool || echo "$2")
\r
81 > + # The test suite forces LC_ALL=C, but this causes Python 3 to
\r
82 > + # decode stdin as ASCII. We need to read JSON in UTF-8, so
\r
83 > + # override Python's stdio encoding defaults.
\r
84 > + output=$(echo "$1" | PYTHONIOENCODING=utf-8 python -mjson.tool \
\r
86 > + expected=$(echo "$2" | PYTHONIOENCODING=utf-8 python -mjson.tool \
\r
89 > test_expect_equal "$output" "$expected" "$@"
\r
94 > _______________________________________________
\r
95 > notmuch mailing list
\r
96 > notmuch@notmuchmail.org
\r
97 > http://notmuchmail.org/mailman/listinfo/notmuch
\r