Make syntax errors prevail over all yamllint problems
This commit is contained in:
@@ -37,8 +37,15 @@ class RuleTestCase(unittest.TestCase):
|
||||
expected_problems = []
|
||||
for key in kwargs:
|
||||
assert key.startswith('problem')
|
||||
if len(kwargs[key]) > 2:
|
||||
if kwargs[key][2] == 'syntax':
|
||||
rule_id = None
|
||||
else:
|
||||
rule_id = kwargs[key][2]
|
||||
else:
|
||||
rule_id = self.rule_id
|
||||
expected_problems.append(
|
||||
LintProblem(kwargs[key][0], kwargs[key][1], rule=self.rule_id))
|
||||
LintProblem(kwargs[key][0], kwargs[key][1], rule=rule_id))
|
||||
expected_problems.sort()
|
||||
|
||||
real_problems = list(lint(source, self.build_fake_config(conf)))
|
||||
|
||||
@@ -82,7 +82,7 @@ class DocumentStartTestCase(RuleTestCase):
|
||||
'...\n'
|
||||
'second: document\n'
|
||||
'---\n'
|
||||
'third: document\n', conf, problem=(4, 1))
|
||||
'third: document\n', conf, problem=(4, 1, 'syntax'))
|
||||
|
||||
def test_directives(self):
|
||||
conf = 'document-start: {present: yes}'
|
||||
|
||||
@@ -163,7 +163,7 @@ class IndentationTestCase(RuleTestCase):
|
||||
self.check('---\n'
|
||||
'- o:\n'
|
||||
' k1: v1\n'
|
||||
'...\n', conf, problem=(3, 2))
|
||||
'...\n', conf, problem=(3, 2, 'syntax'))
|
||||
self.check('---\n'
|
||||
'- o:\n'
|
||||
' k1: v1\n'
|
||||
@@ -192,18 +192,18 @@ class IndentationTestCase(RuleTestCase):
|
||||
' f:\n'
|
||||
'g:\n'
|
||||
'...\n', None)
|
||||
# self.check('---\n'
|
||||
# 'a:\n'
|
||||
# ' b:\n'
|
||||
# ' c:\n'
|
||||
# ' d:\n'
|
||||
# '...\n', None, problem=(5, 5))
|
||||
# self.check('---\n'
|
||||
# 'a:\n'
|
||||
# ' b:\n'
|
||||
# ' c:\n'
|
||||
# ' d:\n'
|
||||
# '...\n', None, problem=(5, 2))
|
||||
self.check('---\n'
|
||||
'a:\n'
|
||||
' b:\n'
|
||||
' c:\n'
|
||||
' d:\n'
|
||||
'...\n', None, problem=(5, 4, 'syntax'))
|
||||
self.check('---\n'
|
||||
'a:\n'
|
||||
' b:\n'
|
||||
' c:\n'
|
||||
' d:\n'
|
||||
'...\n', None, problem=(5, 2, 'syntax'))
|
||||
|
||||
def test_first_line(self):
|
||||
conf = ('indentation: {spaces: 2}\n'
|
||||
|
||||
@@ -33,11 +33,11 @@ class TrailingSpacesTestCase(RuleTestCase):
|
||||
self.check('', conf)
|
||||
self.check('\n', conf)
|
||||
self.check(' \n', conf, problem=(1, 1))
|
||||
self.check('\t\t\t\n', conf, problem=(1, 1))
|
||||
self.check('\t\t\t\n', conf, problem=(1, 1, 'syntax'))
|
||||
self.check('---\n'
|
||||
'some: text \n', conf, problem=(2, 11))
|
||||
self.check('---\n'
|
||||
'some: text\t\n', conf, problem=(2, 11))
|
||||
'some: text\t\n', conf, problem=(2, 11, 'syntax'))
|
||||
|
||||
def test_with_dos_new_lines(self):
|
||||
conf = ('trailing-spaces: {}\n'
|
||||
|
||||
Reference in New Issue
Block a user