From 8426fdd415a29d4ff313daf96b67725061d5c6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Fri, 17 Jul 2020 14:33:30 +0200 Subject: [PATCH] Test --- .travis.yml | 1 + tests/common.py | 3 ++- tests/test_cli.py | 26 ++++++++++++++++++++------ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 44ea648fa..ede6b568d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ install: - pip install pyyaml coveralls flake8 flake8-import-order doc8 - if [[ $TRAVIS_PYTHON_VERSION != 2* ]]; then pip install sphinx; fi - pip install . + - sudo rm -rf /usr/lib/locale/* script: - if [[ $TRAVIS_PYTHON_VERSION != nightly ]]; then flake8 .; fi - if [[ $TRAVIS_PYTHON_VERSION != 2* ]]; then doc8 $(git ls-files '*.rst'); fi diff --git a/tests/common.py b/tests/common.py index b5ba4690b..96fc01819 100644 --- a/tests/common.py +++ b/tests/common.py @@ -57,7 +57,8 @@ def build_temp_workspace(files): tempdir = tempfile.mkdtemp(prefix='yamllint-tests-') for path, content in files.items(): - path = os.path.join(tempdir, path) + path = path if isinstance(path, bytes) else path.encode() + path = os.path.join(tempdir.encode(), path) if not os.path.exists(os.path.dirname(path)): os.makedirs(os.path.dirname(path)) diff --git a/tests/test_cli.py b/tests/test_cli.py index 90cf8c14a..62db777a7 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -86,12 +86,26 @@ def setUpClass(cls): 'no-yaml.json': '---\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'), + # The following bytes work even on systems where C-UTF-8 is not + # available. They are the representation of: + # 'non-ascii/éçäγλνπ¥/utf-8': + # u'---\n' + # u'- hétérogénéité\n' + # u'# 19.99 €\n' + # u'- お早う御座います。\n' + # u'# الأَبْجَدِيَّة العَرَبِيَّة\n' + # b'non-ascii/\xc3\xa9\xc3\xa7\xc3\xa4\xce\xb3\xce\xbb\xce\xbd\xcf' + # b'\x80\xc2\xa5/utf-8': ( + u'non-ascii/éçäγλνπ¥/utf-8'.encode('utf-8'): ( + b'---\n' + b'- h\xc3\xa9t\xc3\xa9rog\xc3\xa9n\xc3\xa9it\xc3\xa9\n' + b'# 19.99 \xe2\x82\xac\n' + b'- \xe3\x81\x8a\xe6\x97\xa9\xe3\x81\x86\xe5\xbe\xa1\xe5\xba' + b'\xa7\xe3\x81\x84\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82\n' + b'# \xd8\xa7\xd9\x84\xd8\xa3\xd9\x8e\xd8\xa8\xd9\x92\xd8\xac' + b'\xd9\x8e\xd8\xaf\xd9\x90\xd9\x8a\xd9\x8e\xd9\x91\xd8\xa9 ' + b'\xd8\xa7\xd9\x84\xd8\xb9\xd9\x8e\xd8\xb1\xd9\x8e\xd8\xa8\xd9' + b'\x90\xd9\x8a\xd9\x8e\xd9\x91\xd8\xa9\n'), # dos line endings yaml 'dos.yml': '---\r\n' 'dos: true',