X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2Ftest-lib.sh;h=948752613dda3e2cf5711b0b477176651c592d60;hp=f1697856426225f2df4de7a6ca9c5c8a384333e5;hb=21326a1e6b23f0dc98d13c93cd5023e148fd1a5d;hpb=2bd922ff06a4e989dc05a1a6739f649c85dae92e diff --git a/test/test-lib.sh b/test/test-lib.sh index f1697856..94875261 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -534,8 +534,13 @@ test_expect_equal_file () # canonicalized before diff'ing. If an argument cannot be parsed, it # is used unchanged so that there's something to diff against. test_expect_equal_json () { - output=$(echo "$1" | python -mjson.tool || echo "$1") - expected=$(echo "$2" | python -mjson.tool || echo "$2") + # The test suite forces LC_ALL=C, but this causes Python 3 to + # decode stdin as ASCII. We need to read JSON in UTF-8, so + # override Python's stdio encoding defaults. + output=$(echo "$1" | PYTHONIOENCODING=utf-8 python -mjson.tool \ + || echo "$1") + expected=$(echo "$2" | PYTHONIOENCODING=utf-8 python -mjson.tool \ + || echo "$2") shift 2 test_expect_equal "$output" "$expected" "$@" }