mirror of
https://github.com/adrienverge/yamllint.git
synced 2025-02-25 18:55:20 -06:00
Tests: Set proper LC_ALL when decoding UTF-8 is needed
Make sure the default localization conditions on the "test system" support UTF-8 encoding.
This commit is contained in:
parent
f4cebdc054
commit
92ff315fb4
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user