|
|
@ -618,7 +618,7 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
def test_direct_flows(self):
|
|
|
|
def test_direct_flows(self):
|
|
|
|
# flow: [ ...
|
|
|
|
# flow: [ ...
|
|
|
|
# ]
|
|
|
|
# ]
|
|
|
|
conf = 'indentation: {spaces: 2}'
|
|
|
|
conf = 'indentation: {spaces: consistent}'
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'a: {x: 1,\n'
|
|
|
|
'a: {x: 1,\n'
|
|
|
|
' y,\n'
|
|
|
|
' y,\n'
|
|
|
@ -670,7 +670,7 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
# flow: [
|
|
|
|
# flow: [
|
|
|
|
# ...
|
|
|
|
# ...
|
|
|
|
# ]
|
|
|
|
# ]
|
|
|
|
conf = 'indentation: {spaces: 2}'
|
|
|
|
conf = 'indentation: {spaces: consistent}'
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'a: {\n'
|
|
|
|
'a: {\n'
|
|
|
|
' x: 1,\n'
|
|
|
|
' x: 1,\n'
|
|
|
@ -758,7 +758,7 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
# [
|
|
|
|
# [
|
|
|
|
# ...
|
|
|
|
# ...
|
|
|
|
# ]
|
|
|
|
# ]
|
|
|
|
conf = 'indentation: {spaces: 2}'
|
|
|
|
conf = 'indentation: {spaces: consistent}'
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'top:\n'
|
|
|
|
'top:\n'
|
|
|
|
' rules:\n'
|
|
|
|
' rules:\n'
|
|
|
@ -808,7 +808,7 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
'top:\n'
|
|
|
|
'top:\n'
|
|
|
|
' [\n'
|
|
|
|
' [\n'
|
|
|
|
' a, b, c\n'
|
|
|
|
' a, b, c\n'
|
|
|
|
' ]\n', conf, problem=(3, 4))
|
|
|
|
' ]\n', conf, problem=(4, 6))
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'top:\n'
|
|
|
|
'top:\n'
|
|
|
|
' [\n'
|
|
|
|
' [\n'
|
|
|
@ -933,7 +933,7 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
problem=(2, 3))
|
|
|
|
problem=(2, 3))
|
|
|
|
|
|
|
|
|
|
|
|
def test_multi_lines(self):
|
|
|
|
def test_multi_lines(self):
|
|
|
|
conf = 'indentation: {spaces: 2, indent-sequences: yes}'
|
|
|
|
conf = 'indentation: {spaces: consistent, indent-sequences: yes}'
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'long_string: >\n'
|
|
|
|
'long_string: >\n'
|
|
|
|
' bla bla blah\n'
|
|
|
|
' bla bla blah\n'
|
|
|
@ -952,7 +952,7 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
'...\n', conf)
|
|
|
|
'...\n', conf)
|
|
|
|
|
|
|
|
|
|
|
|
def test_empty_value(self):
|
|
|
|
def test_empty_value(self):
|
|
|
|
conf = 'indentation: {spaces: 2}'
|
|
|
|
conf = 'indentation: {spaces: consistent}'
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'key1:\n'
|
|
|
|
'key1:\n'
|
|
|
|
'key2: not empty\n'
|
|
|
|
'key2: not empty\n'
|
|
|
@ -1007,7 +1007,7 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
'...\n', conf, problem=(2, 2))
|
|
|
|
'...\n', conf, problem=(2, 2))
|
|
|
|
|
|
|
|
|
|
|
|
def test_return(self):
|
|
|
|
def test_return(self):
|
|
|
|
conf = 'indentation: {spaces: 2}'
|
|
|
|
conf = 'indentation: {spaces: consistent}'
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'a:\n'
|
|
|
|
'a:\n'
|
|
|
|
' b:\n'
|
|
|
|
' b:\n'
|
|
|
@ -1031,12 +1031,12 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
'...\n', conf, problem=(5, 2, 'syntax'))
|
|
|
|
'...\n', conf, problem=(5, 2, 'syntax'))
|
|
|
|
|
|
|
|
|
|
|
|
def test_first_line(self):
|
|
|
|
def test_first_line(self):
|
|
|
|
conf = ('indentation: {spaces: 2}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check(' a: 1\n', conf, problem=(1, 3))
|
|
|
|
self.check(' a: 1\n', conf, problem=(1, 3))
|
|
|
|
|
|
|
|
|
|
|
|
def test_explicit_block_mappings(self):
|
|
|
|
def test_explicit_block_mappings(self):
|
|
|
|
conf = 'indentation: {spaces: 4}'
|
|
|
|
conf = 'indentation: {spaces: consistent}'
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'object:\n'
|
|
|
|
'object:\n'
|
|
|
|
' ? key\n'
|
|
|
|
' ? key\n'
|
|
|
@ -1072,7 +1072,7 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
'...\n', conf, problem1=(4, 10), problem2=(6, 8))
|
|
|
|
'...\n', conf, problem1=(4, 10), problem2=(6, 8))
|
|
|
|
|
|
|
|
|
|
|
|
def test_clear_sequence_item(self):
|
|
|
|
def test_clear_sequence_item(self):
|
|
|
|
conf = 'indentation: {spaces: 2}'
|
|
|
|
conf = 'indentation: {spaces: consistent}'
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'-\n'
|
|
|
|
'-\n'
|
|
|
|
' string\n'
|
|
|
|
' string\n'
|
|
|
@ -1091,17 +1091,17 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
'-\n'
|
|
|
|
'-\n'
|
|
|
|
' string\n'
|
|
|
|
' string\n'
|
|
|
|
'-\n'
|
|
|
|
'-\n'
|
|
|
|
' string\n', conf, problem1=(3, 2), problem2=(5, 4))
|
|
|
|
' string\n', conf, problem=(5, 4))
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'-\n'
|
|
|
|
'-\n'
|
|
|
|
' map: ping\n'
|
|
|
|
' map: ping\n'
|
|
|
|
'-\n'
|
|
|
|
'-\n'
|
|
|
|
' map: ping\n', conf, problem1=(3, 2), problem2=(5, 4))
|
|
|
|
' map: ping\n', conf, problem=(5, 4))
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'-\n'
|
|
|
|
'-\n'
|
|
|
|
' - sequence\n'
|
|
|
|
' - sequence\n'
|
|
|
|
'-\n'
|
|
|
|
'-\n'
|
|
|
|
' - sequence\n', conf, problem1=(3, 2), problem2=(5, 4))
|
|
|
|
' - sequence\n', conf, problem=(5, 4))
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'-\n'
|
|
|
|
'-\n'
|
|
|
|
' -\n'
|
|
|
|
' -\n'
|
|
|
@ -1115,9 +1115,31 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
' multi\n'
|
|
|
|
' multi\n'
|
|
|
|
' line\n'
|
|
|
|
' line\n'
|
|
|
|
'...\n', conf, problem=(4, 6))
|
|
|
|
'...\n', conf, problem=(4, 6))
|
|
|
|
|
|
|
|
conf = 'indentation: {spaces: 2}'
|
|
|
|
|
|
|
|
self.check('---\n'
|
|
|
|
|
|
|
|
'-\n'
|
|
|
|
|
|
|
|
' string\n'
|
|
|
|
|
|
|
|
'-\n'
|
|
|
|
|
|
|
|
' string\n', conf, problem1=(3, 2), problem2=(5, 4))
|
|
|
|
|
|
|
|
self.check('---\n'
|
|
|
|
|
|
|
|
'-\n'
|
|
|
|
|
|
|
|
' map: ping\n'
|
|
|
|
|
|
|
|
'-\n'
|
|
|
|
|
|
|
|
' map: ping\n', conf, problem1=(3, 2), problem2=(5, 4))
|
|
|
|
|
|
|
|
self.check('---\n'
|
|
|
|
|
|
|
|
'-\n'
|
|
|
|
|
|
|
|
' - sequence\n'
|
|
|
|
|
|
|
|
'-\n'
|
|
|
|
|
|
|
|
' - sequence\n', conf, problem1=(3, 2), problem2=(5, 4))
|
|
|
|
|
|
|
|
self.check('---\n'
|
|
|
|
|
|
|
|
'-\n'
|
|
|
|
|
|
|
|
' -\n'
|
|
|
|
|
|
|
|
' nested\n'
|
|
|
|
|
|
|
|
' -\n'
|
|
|
|
|
|
|
|
' nested\n', conf, problem1=(4, 4), problem2=(6, 6))
|
|
|
|
|
|
|
|
|
|
|
|
def test_anchors(self):
|
|
|
|
def test_anchors(self):
|
|
|
|
conf = 'indentation: {spaces: 2}'
|
|
|
|
conf = 'indentation: {spaces: consistent}'
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'key: &anchor value\n', conf)
|
|
|
|
'key: &anchor value\n', conf)
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
@ -1177,7 +1199,7 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
' - k: *a\n', conf)
|
|
|
|
' - k: *a\n', conf)
|
|
|
|
|
|
|
|
|
|
|
|
def test_tags(self):
|
|
|
|
def test_tags(self):
|
|
|
|
conf = 'indentation: {spaces: 2}'
|
|
|
|
conf = 'indentation: {spaces: consistent}'
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'-\n'
|
|
|
|
'-\n'
|
|
|
|
' "flow in block"\n'
|
|
|
|
' "flow in block"\n'
|
|
|
@ -1186,7 +1208,7 @@ class IndentationTestCase(RuleTestCase):
|
|
|
|
'- !!map # Block collection\n'
|
|
|
|
'- !!map # Block collection\n'
|
|
|
|
' foo: bar\n', conf)
|
|
|
|
' foo: bar\n', conf)
|
|
|
|
|
|
|
|
|
|
|
|
conf = 'indentation: {spaces: 2, indent-sequences: no}'
|
|
|
|
conf = 'indentation: {spaces: consistent, indent-sequences: no}'
|
|
|
|
self.check('---\n'
|
|
|
|
self.check('---\n'
|
|
|
|
'sequence: !!seq\n'
|
|
|
|
'sequence: !!seq\n'
|
|
|
|
'- entry\n'
|
|
|
|
'- entry\n'
|
|
|
@ -1210,7 +1232,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
rule_id = 'indentation'
|
|
|
|
rule_id = 'indentation'
|
|
|
|
|
|
|
|
|
|
|
|
def test_basics_plain(self):
|
|
|
|
def test_basics_plain(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: no}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: no}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('multi\n'
|
|
|
|
self.check('multi\n'
|
|
|
|
'line\n', conf)
|
|
|
|
'line\n', conf)
|
|
|
@ -1238,7 +1261,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
' }\n', conf)
|
|
|
|
' }\n', conf)
|
|
|
|
|
|
|
|
|
|
|
|
def test_check_multi_line_plain(self):
|
|
|
|
def test_check_multi_line_plain(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: yes}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: yes}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('multi\n'
|
|
|
|
self.check('multi\n'
|
|
|
|
' line\n', conf, problem=(2, 2))
|
|
|
|
' line\n', conf, problem=(2, 2))
|
|
|
@ -1260,7 +1284,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
' }\n', conf, problem=(3, 9))
|
|
|
|
' }\n', conf, problem=(3, 9))
|
|
|
|
|
|
|
|
|
|
|
|
def test_basics_quoted(self):
|
|
|
|
def test_basics_quoted(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: no}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: no}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('"multi\n'
|
|
|
|
self.check('"multi\n'
|
|
|
|
' line"\n', conf)
|
|
|
|
' line"\n', conf)
|
|
|
@ -1290,7 +1315,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
' line 2"]\n', conf)
|
|
|
|
' line 2"]\n', conf)
|
|
|
|
|
|
|
|
|
|
|
|
def test_check_multi_line_quoted(self):
|
|
|
|
def test_check_multi_line_quoted(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: yes}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: yes}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('"multi\n'
|
|
|
|
self.check('"multi\n'
|
|
|
|
'line"\n', conf, problem=(2, 1))
|
|
|
|
'line"\n', conf, problem=(2, 1))
|
|
|
@ -1345,7 +1371,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
' line 2"]\n', conf, problem=(3, 14))
|
|
|
|
' line 2"]\n', conf, problem=(3, 14))
|
|
|
|
|
|
|
|
|
|
|
|
def test_basics_folded_style(self):
|
|
|
|
def test_basics_folded_style(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: no}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: no}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('>\n'
|
|
|
|
self.check('>\n'
|
|
|
|
' multi\n'
|
|
|
|
' multi\n'
|
|
|
@ -1382,7 +1409,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
' {% endif %}\n', conf)
|
|
|
|
' {% endif %}\n', conf)
|
|
|
|
|
|
|
|
|
|
|
|
def test_check_multi_line_folded_style(self):
|
|
|
|
def test_check_multi_line_folded_style(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: yes}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: yes}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('>\n'
|
|
|
|
self.check('>\n'
|
|
|
|
' multi\n'
|
|
|
|
' multi\n'
|
|
|
@ -1422,7 +1450,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
problem1=(3, 7), problem2=(5, 7))
|
|
|
|
problem1=(3, 7), problem2=(5, 7))
|
|
|
|
|
|
|
|
|
|
|
|
def test_basics_literal_style(self):
|
|
|
|
def test_basics_literal_style(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: no}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: no}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('|\n'
|
|
|
|
self.check('|\n'
|
|
|
|
' multi\n'
|
|
|
|
' multi\n'
|
|
|
@ -1459,7 +1488,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
' {% endif %}\n', conf)
|
|
|
|
' {% endif %}\n', conf)
|
|
|
|
|
|
|
|
|
|
|
|
def test_check_multi_line_literal_style(self):
|
|
|
|
def test_check_multi_line_literal_style(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: yes}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: yes}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('|\n'
|
|
|
|
self.check('|\n'
|
|
|
|
' multi\n'
|
|
|
|
' multi\n'
|
|
|
@ -1502,7 +1532,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
# http://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines
|
|
|
|
# http://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines
|
|
|
|
|
|
|
|
|
|
|
|
def test_paragraph_plain(self):
|
|
|
|
def test_paragraph_plain(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: yes}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: yes}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('- long text: very "long"\n'
|
|
|
|
self.check('- long text: very "long"\n'
|
|
|
|
' \'string\' with\n'
|
|
|
|
' \'string\' with\n'
|
|
|
@ -1523,7 +1554,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
' spaces.\n', conf)
|
|
|
|
' spaces.\n', conf)
|
|
|
|
|
|
|
|
|
|
|
|
def test_paragraph_double_quoted(self):
|
|
|
|
def test_paragraph_double_quoted(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: yes}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: yes}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('- long text: "very \\"long\\"\n'
|
|
|
|
self.check('- long text: "very \\"long\\"\n'
|
|
|
|
' \'string\' with\n'
|
|
|
|
' \'string\' with\n'
|
|
|
@ -1550,7 +1582,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
' spaces."\n', conf)
|
|
|
|
' spaces."\n', conf)
|
|
|
|
|
|
|
|
|
|
|
|
def test_paragraph_single_quoted(self):
|
|
|
|
def test_paragraph_single_quoted(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: yes}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: yes}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('- long text: \'very "long"\n'
|
|
|
|
self.check('- long text: \'very "long"\n'
|
|
|
|
' \'\'string\'\' with\n'
|
|
|
|
' \'\'string\'\' with\n'
|
|
|
@ -1577,7 +1610,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
' spaces.\'\n', conf)
|
|
|
|
' spaces.\'\n', conf)
|
|
|
|
|
|
|
|
|
|
|
|
def test_paragraph_folded(self):
|
|
|
|
def test_paragraph_folded(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: yes}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: yes}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('- long text: >\n'
|
|
|
|
self.check('- long text: >\n'
|
|
|
|
' very "long"\n'
|
|
|
|
' very "long"\n'
|
|
|
@ -1594,7 +1628,8 @@ class ScalarIndentationTestCase(RuleTestCase):
|
|
|
|
problem1=(3, 6), problem2=(5, 7), problem3=(6, 8))
|
|
|
|
problem1=(3, 6), problem2=(5, 7), problem3=(6, 8))
|
|
|
|
|
|
|
|
|
|
|
|
def test_paragraph_literal(self):
|
|
|
|
def test_paragraph_literal(self):
|
|
|
|
conf = ('indentation: {spaces: 2, check-multi-line-strings: yes}\n'
|
|
|
|
conf = ('indentation: {spaces: consistent,\n'
|
|
|
|
|
|
|
|
' check-multi-line-strings: yes}\n'
|
|
|
|
'document-start: disable\n')
|
|
|
|
'document-start: disable\n')
|
|
|
|
self.check('- long text: |\n'
|
|
|
|
self.check('- long text: |\n'
|
|
|
|
' very "long"\n'
|
|
|
|
' very "long"\n'
|
|
|
|