fix build_temp_workspace
This commit is contained in:
@@ -57,7 +57,7 @@ def build_temp_workspace(files):
|
|||||||
tempdir = tempfile.mkdtemp(prefix='yamllint-tests-')
|
tempdir = tempfile.mkdtemp(prefix='yamllint-tests-')
|
||||||
|
|
||||||
for path, content in files.items():
|
for path, content in files.items():
|
||||||
path = os.path.join(tempdir, path)
|
path = os.path.join(tempdir, path).encode('utf-8')
|
||||||
if not os.path.exists(os.path.dirname(path)):
|
if not os.path.exists(os.path.dirname(path)):
|
||||||
os.makedirs(os.path.dirname(path))
|
os.makedirs(os.path.dirname(path))
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class CommandLineTestCase(unittest.TestCase):
|
|||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(CommandLineTestCase, cls).setUpClass()
|
super(CommandLineTestCase, cls).setUpClass()
|
||||||
|
|
||||||
workspace_def = {
|
cls.wd = build_temp_workspace({
|
||||||
# .yaml file at root
|
# .yaml file at root
|
||||||
'a.yaml': '---\n'
|
'a.yaml': '---\n'
|
||||||
'- 1 \n'
|
'- 1 \n'
|
||||||
@@ -98,6 +98,13 @@ class CommandLineTestCase(unittest.TestCase):
|
|||||||
# non-YAML file
|
# non-YAML file
|
||||||
'no-yaml.json': '---\n'
|
'no-yaml.json': '---\n'
|
||||||
'key: value\n',
|
'key: value\n',
|
||||||
|
# non-ASCII chars
|
||||||
|
'non-ascii/éçäγλνπ¥/utf-8': (
|
||||||
|
u'---\n'
|
||||||
|
u'- hétérogénéité\n'
|
||||||
|
u'# 19.99 €\n'
|
||||||
|
u'- お早う御座います。\n'
|
||||||
|
u'# الأَبْجَدِيَّة العَرَبِيَّة\n').encode('utf-8'),
|
||||||
# dos line endings yaml
|
# dos line endings yaml
|
||||||
'dos.yml': '---\r\n'
|
'dos.yml': '---\r\n'
|
||||||
'dos: true',
|
'dos: true',
|
||||||
@@ -108,18 +115,7 @@ class CommandLineTestCase(unittest.TestCase):
|
|||||||
'en.yaml': '---\n'
|
'en.yaml': '---\n'
|
||||||
'a: true\n'
|
'a: true\n'
|
||||||
'A: true'
|
'A: true'
|
||||||
}
|
})
|
||||||
|
|
||||||
if utf8_paths_supported():
|
|
||||||
# non-ASCII chars
|
|
||||||
workspace_def['non-ascii/éçäγλνπ¥/utf-8'] = (
|
|
||||||
u'---\n'
|
|
||||||
u'- hétérogénéité\n'
|
|
||||||
u'# 19.99 €\n'
|
|
||||||
u'- お早う御座います。\n'
|
|
||||||
u'# الأَبْجَدِيَّة العَرَبِيَّة\n').encode('utf-8')
|
|
||||||
|
|
||||||
cls.wd = build_temp_workspace(workspace_def)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
@@ -445,7 +441,6 @@ class CommandLineTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
@unittest.skipIf(not utf8_paths_supported(), 'UTF-8 paths not supported')
|
@unittest.skipIf(not utf8_paths_supported(), 'UTF-8 paths not supported')
|
||||||
def test_run_non_ascii_file(self):
|
def test_run_non_ascii_file(self):
|
||||||
if sys.version_info < (3, 7):
|
|
||||||
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
|
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
|
||||||
self.addCleanup(locale.setlocale, locale.LC_ALL, (None, None))
|
self.addCleanup(locale.setlocale, locale.LC_ALL, (None, None))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user