1 Return-Path: <amdragon@mit.edu>
\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 6C48D431FB6
\r
6 for <notmuch@notmuchmail.org>; Tue, 4 Dec 2012 07:24:25 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\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 tUpnjUcjgZ0e for <notmuch@notmuchmail.org>;
\r
16 Tue, 4 Dec 2012 07:24:21 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 76DE1431FAE
\r
20 for <notmuch@notmuchmail.org>; Tue, 4 Dec 2012 07:24:21 -0800 (PST)
\r
21 X-AuditID: 1209190e-b7f516d0000008e4-f5-50be15a43521
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 23.95.02276.4A51EB05; Tue, 4 Dec 2012 10:24:20 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qB4FOJN5009216;
\r
27 Tue, 4 Dec 2012 10:24:19 -0500
\r
28 Received: from drake.dyndns.org
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qB4FOG6A012417
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Tue, 4 Dec 2012 10:24:18 -0500 (EST)
\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
36 (envelope-from <amdragon@mit.edu>)
\r
37 id 1TfuM4-0002Ux-Iv; Tue, 04 Dec 2012 10:24:16 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH] test: Fix UTF-8 JSON tests in Python 3
\r
41 Date: Tue, 4 Dec 2012 10:24:14 -0500
\r
42 Message-Id: <1354634654-9564-1-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.10.4
\r
44 In-Reply-To: <87d2yp27zu.fsf@nexoid.at>
\r
45 References: <87d2yp27zu.fsf@nexoid.at>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixCmqrLtEdF+AwZ5fNhZ7G9oZLa7fnMns
\r
48 wOSxeNN+No9nq24xBzBFcdmkpOZklqUW6dslcGVMf/iUseAvd8WV3weZGhiPcnYxcnJICJhI
\r
49 7Duzkg3CFpO4cG89kM3FISSwj1Fi+rezrBDOekaJ/mV/mCCch0wSy1pvgbUICcxllHjzWA/E
\r
50 ZhPQkNi2fzkjiC0iIC2x8+5sVhCbWcBMYu7PiWD1wgLmEnM7J4HVsAioSrxZf5ili5GDg1fA
\r
51 XuLCLluIKxQlup9NACvnFFCXWPhjHiPEKjWJaSces05g5F/AyLCKUTYlt0o3NzEzpzg1Wbc4
\r
52 OTEvL7VI11gvN7NELzWldBMjOJAk+XYwfj2odIhRgINRiYd3wq09AUKsiWXFlbmHGCU5mJRE
\r
53 eY2F9wUI8SXlp1RmJBZnxBeV5qQWH2KU4GBWEuFV+LA3QIg3JbGyKrUoHyYlzcGiJM57JeWm
\r
54 v5BAemJJanZqakFqEUxWhoNDSYJ3kQjQUMGi1PTUirTMnBKENBMHJ8hwHqDhWSA1vMUFibnF
\r
55 mekQ+VOMilLivKwgCQGQREZpHlwvLNJfMYoDvSLMew3kbh5gkoDrfgU0mAlo8Auh3SCDSxIR
\r
56 UlINjB3bLylOPxMoMt94/czWZ9LcLNpdJ67/tAwwkE26tvW+3KfEvoLYTTu+iR2YbvP+A+O2
\r
57 jheBB4U4/81QdO5et+Zd4A/5P3pBVzJ+lcRk2+hxTXQ0ZLwlFt4sND/hg63Mx23fdzmw3/lq
\r
58 EW/4dlJp1d3TLpa7XU6sPfgg8VTpl8AVqszqwe8bYpRYijMSDbWYi4oTAXKN1AnPAgAA
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Tue, 04 Dec 2012 15:24:25 -0000
\r
73 test_expect_equal_json uses json.tool from the system Python. While
\r
74 Python 2 wasn't picky about the encoding of stdin, Python 3 decodes
\r
75 stdin strictly according to the environment. Since we set LC_ALL=C
\r
76 for the tests, Python 3's json.tool was assuming stdin would be in
\r
77 ASCII and aborting when it couldn't decode the UTF-8 characters from
\r
78 some of the JSON tests. This patch sets the PYTHONIOENCODING
\r
79 environment variable to utf-8 when invoking json.tool to override
\r
80 Python's default encoding choice.
\r
82 test/test-lib.sh | 9 +++++++--
\r
83 1 file changed, 7 insertions(+), 2 deletions(-)
\r
85 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
86 index f169785..9487526 100644
\r
87 --- a/test/test-lib.sh
\r
88 +++ b/test/test-lib.sh
\r
89 @@ -534,8 +534,13 @@ test_expect_equal_file ()
\r
90 # canonicalized before diff'ing. If an argument cannot be parsed, it
\r
91 # is used unchanged so that there's something to diff against.
\r
92 test_expect_equal_json () {
\r
93 - output=$(echo "$1" | python -mjson.tool || echo "$1")
\r
94 - expected=$(echo "$2" | python -mjson.tool || echo "$2")
\r
95 + # The test suite forces LC_ALL=C, but this causes Python 3 to
\r
96 + # decode stdin as ASCII. We need to read JSON in UTF-8, so
\r
97 + # override Python's stdio encoding defaults.
\r
98 + output=$(echo "$1" | PYTHONIOENCODING=utf-8 python -mjson.tool \
\r
100 + expected=$(echo "$2" | PYTHONIOENCODING=utf-8 python -mjson.tool \
\r
103 test_expect_equal "$output" "$expected" "$@"
\r