From 164a9920e74c8cce150704d8bfcb2a7e4d47956d Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Mon, 26 Nov 2018 10:01:42 -0800 Subject: [PATCH] Test: Look up our encoding name before checking it. Resolve our output encoding name to something that's hopefully the same on all platforms so that we don't print Warning: Output encoding is utf-8 and not UTF-8. on Windows. Change-Id: I9c7703eac6e12f5a95f701e8a9bea7d17a513fef Reviewed-on: https://code.wireshark.org/review/30795 Reviewed-by: Gerald Combs Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- test/test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test.py b/test/test.py index f775bae85c..c64891bb1c 100755 --- a/test/test.py +++ b/test/test.py @@ -16,6 +16,7 @@ import argparse +import codecs import os.path import sys import unittest @@ -121,10 +122,9 @@ def main(): print('\n'.join(list(cases))) sys.exit(0) - if sys.stdout.encoding != 'UTF-8': - import codecs + if codecs.lookup(sys.stdout.encoding).name != 'utf-8': import locale - sys.stderr.write('Warning: Output encoding is {0} and not UTF-8.\n'.format(sys.stdout.encoding)) + sys.stderr.write('Warning: Output encoding is {0} and not utf-8.\n'.format(sys.stdout.encoding)) sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout.buffer, 'backslashreplace') sys.stderr = codecs.getwriter(locale.getpreferredencoding())(sys.stderr.buffer, 'backslashreplace')