|
|
@ -23,62 +23,45 @@ import locale
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import pty
|
|
|
|
import pty
|
|
|
|
import shutil
|
|
|
|
import shutil
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import unittest
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
from yamllint import cli
|
|
|
|
from yamllint import cli
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from tests.common import build_temp_workspace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CommandLineTestCase(unittest.TestCase):
|
|
|
|
class CommandLineTestCase(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
def setUp(self):
|
|
|
|
self.wd = tempfile.mkdtemp(prefix='yamllint-tests-')
|
|
|
|
self.wd = build_temp_workspace({
|
|
|
|
|
|
|
|
|
|
|
|
# .yaml file at root
|
|
|
|
# .yaml file at root
|
|
|
|
with open(os.path.join(self.wd, 'a.yaml'), 'w') as f:
|
|
|
|
'a.yaml': '---\n'
|
|
|
|
f.write('---\n'
|
|
|
|
|
|
|
|
'- 1 \n'
|
|
|
|
'- 1 \n'
|
|
|
|
'- 2')
|
|
|
|
'- 2',
|
|
|
|
|
|
|
|
|
|
|
|
# file with only one warning
|
|
|
|
# file with only one warning
|
|
|
|
with open(os.path.join(self.wd, 'warn.yaml'), 'w') as f:
|
|
|
|
'warn.yaml': 'key: value\n',
|
|
|
|
f.write('key: value\n')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# .yml file at root
|
|
|
|
# .yml file at root
|
|
|
|
open(os.path.join(self.wd, 'empty.yml'), 'w').close()
|
|
|
|
'empty.yml': '',
|
|
|
|
|
|
|
|
|
|
|
|
# file in dir
|
|
|
|
# file in dir
|
|
|
|
os.mkdir(os.path.join(self.wd, 'sub'))
|
|
|
|
'sub/ok.yaml': '---\n'
|
|
|
|
with open(os.path.join(self.wd, 'sub', 'ok.yaml'), 'w') as f:
|
|
|
|
'key: value\n',
|
|
|
|
f.write('---\n'
|
|
|
|
|
|
|
|
'key: value\n')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# file in very nested dir
|
|
|
|
# file in very nested dir
|
|
|
|
dir = self.wd
|
|
|
|
's/s/s/s/s/s/s/s/s/s/s/s/s/s/s/file.yaml': '---\n'
|
|
|
|
for i in range(15):
|
|
|
|
|
|
|
|
dir = os.path.join(dir, 's')
|
|
|
|
|
|
|
|
os.mkdir(dir)
|
|
|
|
|
|
|
|
with open(os.path.join(dir, 'file.yaml'), 'w') as f:
|
|
|
|
|
|
|
|
f.write('---\n'
|
|
|
|
|
|
|
|
'key: value\n'
|
|
|
|
'key: value\n'
|
|
|
|
'key: other value\n')
|
|
|
|
'key: other value\n',
|
|
|
|
|
|
|
|
|
|
|
|
# empty dir
|
|
|
|
# empty dir
|
|
|
|
os.mkdir(os.path.join(self.wd, 'empty-dir'))
|
|
|
|
'empty-dir': [],
|
|
|
|
|
|
|
|
|
|
|
|
# non-YAML file
|
|
|
|
# non-YAML file
|
|
|
|
with open(os.path.join(self.wd, 'no-yaml.json'), 'w') as f:
|
|
|
|
'no-yaml.json': '---\n'
|
|
|
|
f.write('---\n'
|
|
|
|
'key: value\n',
|
|
|
|
'key: value\n')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# non-ASCII chars
|
|
|
|
# non-ASCII chars
|
|
|
|
os.mkdir(os.path.join(self.wd, 'non-ascii'))
|
|
|
|
'non-ascii/utf-8': (
|
|
|
|
with open(os.path.join(self.wd, 'non-ascii', 'utf-8'), 'wb') as f:
|
|
|
|
u'---\n'
|
|
|
|
f.write((u'---\n'
|
|
|
|
|
|
|
|
u'- hétérogénéité\n'
|
|
|
|
u'- hétérogénéité\n'
|
|
|
|
u'# 19.99 €\n'
|
|
|
|
u'# 19.99 €\n'
|
|
|
|
u'- お早う御座います。\n'
|
|
|
|
u'- お早う御座います。\n'
|
|
|
|
u'# الأَبْجَدِيَّة العَرَبِيَّة\n').encode('utf-8'))
|
|
|
|
u'# الأَبْجَدِيَّة العَرَبِيَّة\n').encode('utf-8'),
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
def tearDown(self):
|
|
|
|
shutil.rmtree(self.wd)
|
|
|
|
shutil.rmtree(self.wd)
|
|
|
|