From ed5d319df87a7bdced29454a3a0b01954b2b5174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Sun, 5 Nov 2017 09:59:16 +0100 Subject: [PATCH] tests: Use en_US.UTF-8 locale when C.UTF-8 not available Some operating systems don't have the `C.UTF-8` locale installed yet (for instance, CentOS 7). In such a case, fallback to `en_US.UTF-8` so that tests can be run. This follows commit 92ff315. --- tests/test_cli.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index e903d57..47b5daf 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -299,7 +299,10 @@ class CommandLineTestCase(unittest.TestCase): # Make sure the default localization conditions on this "system" # support UTF-8 encoding. loc = locale.getlocale() - locale.setlocale(locale.LC_ALL, 'C.UTF-8') + try: + locale.setlocale(locale.LC_ALL, 'C.UTF-8') + except locale.Error: + locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') sys.stdout, sys.stderr = StringIO(), StringIO() with self.assertRaises(SystemExit) as ctx: