Test: Look up our encoding name before checking it.
authorGerald Combs <gerald@wireshark.org>
Mon, 26 Nov 2018 18:01:42 +0000 (10:01 -0800)
committerAnders Broman <a.broman58@gmail.com>
Tue, 27 Nov 2018 04:40:47 +0000 (04:40 +0000)
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 <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
test/test.py

index f775bae85c5d829b54a19dbb65f2927d383822ef..c64891bb1ce163bee2e1a410238d1721cde9a6ab 100755 (executable)
@@ -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')