diff --git a/tests/test_cli.py b/tests/test_cli.py index ec40a32..ed4e76d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -18,6 +18,7 @@ try: from cStringIO import StringIO except ImportError: from io import StringIO +import locale import os import shutil import tempfile @@ -273,10 +274,17 @@ class CommandLineTestCase(unittest.TestCase): def test_run_non_ascii_file(self): file = os.path.join(self.wd, 'non-ascii', 'utf-8') + # Make sure the default localization conditions on this "system" + # support UTF-8 encoding. + loc = locale.getlocale() + locale.setlocale(locale.LC_ALL, 'C.UTF-8') + sys.stdout, sys.stderr = StringIO(), StringIO() with self.assertRaises(SystemExit) as ctx: cli.run(('-f', 'parsable', file)) + locale.setlocale(locale.LC_ALL, loc) + self.assertEqual(ctx.exception.code, 0) out, err = sys.stdout.getvalue(), sys.stderr.getvalue()