summaryrefslogtreecommitdiff
path: root/_test/test_indentation.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2017-08-14 20:44:09 +0200
committerAnthon van der Neut <anthon@mnt.org>2017-08-14 20:44:09 +0200
commit4c7259963b3f1bd92e7f5a863a737ef008e0e6dd (patch)
tree8b163f23fd56eac04246417cef96ca927a561ca2 /_test/test_indentation.py
parent21c1662a4c8367e1ce48811f78bcfe2830d06d58 (diff)
downloadruamel.yaml-4c7259963b3f1bd92e7f5a863a737ef008e0e6dd.tar.gz
fix issue #51: separate indent levels for mappings and sequences0.15.29
**When this resolves the reported problem, please close this issue**
Diffstat (limited to '_test/test_indentation.py')
-rw-r--r--_test/test_indentation.py76
1 files changed, 75 insertions, 1 deletions
diff --git a/_test/test_indentation.py b/_test/test_indentation.py
index 4391013..4e991fd 100644
--- a/_test/test_indentation.py
+++ b/_test/test_indentation.py
@@ -10,7 +10,7 @@ import pytest # NOQA
import ruamel.yaml
from ruamel.yaml.util import load_yaml_guess_indent
-from roundtrip import round_trip, round_trip_load, round_trip_dump, dedent
+from roundtrip import round_trip, round_trip_load, round_trip_dump, dedent, YAML
def rt(s):
@@ -240,4 +240,78 @@ class TestGuessIndent:
a: 1
""") == (3, None)
+
+class TestSeparateMapSeqIndents:
+ # using uncommon 6 indent with 3 push in as 2 push in automatically
+ # gets you 4 indent even if not set
+ def test_00(self):
+ # old style
+ yaml = YAML()
+ yaml.indent = 6
+ yaml.block_seq_indent = 3
+ yaml.round_trip("""
+ a:
+ - 1
+ - [1, 2]
+ """)
+
+ def test_01(self):
+ yaml = YAML()
+ yaml.indent(sequence=6)
+ yaml.indent(offset=3)
+ yaml.round_trip("""
+ a:
+ - 1
+ - {b: 3}
+ """)
+
+ def test_02(self):
+ yaml = YAML()
+ yaml.indent(mapping=5, sequence=6, offset=3)
+ yaml.round_trip("""
+ a:
+ b:
+ - 1
+ - [1, 2]
+ """)
+
+ def test_03(self):
+ round_trip("""
+ a:
+ b:
+ c:
+ - 1
+ - [1, 2]
+ """, indent=4)
+
+ def test_04(self):
+ yaml = YAML()
+ yaml.indent(mapping=5, sequence=6)
+ yaml.round_trip("""
+ a:
+ b:
+ - 1
+ - [1, 2]
+ - {d: 3.14}
+ """)
+
+ def test_issue_51(self):
+ yaml = YAML()
+ # yaml.map_indent = 2 # the default
+ yaml.sequence_indent = 4
+ yaml.sequence_dash_offset = 2
+ yaml.preserve_quotes = True
+ yaml.round_trip("""
+ role::startup::author::rsyslog_inputs:
+ imfile:
+ - ruleset: 'AEM-slinglog'
+ File: '/opt/aem/author/crx-quickstart/logs/error.log'
+ startmsg.regex: '^[-+T.:[:digit:]]*'
+ tag: 'error'
+ - ruleset: 'AEM-slinglog'
+ File: '/opt/aem/author/crx-quickstart/logs/stdout.log'
+ startmsg.regex: '^[-+T.:[:digit:]]*'
+ tag: 'stdout'
+ """)
+
# ############ indentation