diff options
author | Anthon van der Neut <anthon@mnt.org> | 2019-05-16 22:53:16 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2019-05-16 22:53:16 +0200 |
commit | 6f802bba09690a61d753910119811167016b8ab7 (patch) | |
tree | 2929e547d8ade18cd6cb466212029d782d773471 /_test | |
parent | 79ce3ac7ab98fee2a2896e38113135d3679920de (diff) | |
download | ruamel.yaml-6f802bba09690a61d753910119811167016b8ab7.tar.gz |
indentation of comments after folded/lit scalars0.15.96
fixes issue #290
*When this change indeed resolves your problem, please **Close** this issue*.
*(You can do so using the WorkFlow pull-down (close to the top right of this page))*
Diffstat (limited to '_test')
-rw-r--r-- | _test/test_issues.py | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/_test/test_issues.py b/_test/test_issues.py index ec7d95d..990d538 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -695,6 +695,109 @@ class TestIssues: yaml.dump(data, buf) assert buf.getvalue() == yamldoc + def test_issue_288a(self): + import sys + from ruamel.yaml.compat import StringIO + from ruamel.yaml import YAML + + yamldoc = dedent("""\ + --- + # Reusable values + aliases: + # First-element comment + - &firstEntry First entry + # Second-element comment + - &secondEntry Second entry + + # Third-element comment is + # a multi-line value + - &thirdEntry Third entry + + # EOF Comment + """) + + yaml = YAML() + yaml.indent(mapping=2, sequence=4, offset=2) + yaml.explicit_start = True + yaml.preserve_quotes = True + yaml.width = sys.maxsize + data = yaml.load(yamldoc) + buf = StringIO() + yaml.dump(data, buf) + assert buf.getvalue() == yamldoc + + def test_issue_290(self): + import sys + from ruamel.yaml.compat import StringIO + from ruamel.yaml import YAML + + yamldoc = dedent("""\ + --- + aliases: + # Folded-element comment + # for a multi-line value + - &FoldedEntry > + THIS IS A + FOLDED, MULTI-LINE + VALUE + + # Literal-element comment + # for a multi-line value + - &literalEntry | + THIS IS A + LITERAL, MULTI-LINE + VALUE + + # Plain-element comment + - &plainEntry Plain entry + """) + + yaml = YAML() + yaml.indent(mapping=2, sequence=4, offset=2) + yaml.explicit_start = True + yaml.preserve_quotes = True + yaml.width = sys.maxsize + data = yaml.load(yamldoc) + buf = StringIO() + yaml.dump(data, buf) + assert buf.getvalue() == yamldoc + + def test_issue_290a(self): + import sys + from ruamel.yaml.compat import StringIO + from ruamel.yaml import YAML + + yamldoc = dedent("""\ + --- + aliases: + # Folded-element comment + # for a multi-line value + - &FoldedEntry > + THIS IS A + FOLDED, MULTI-LINE + VALUE + + # Literal-element comment + # for a multi-line value + - &literalEntry | + THIS IS A + LITERAL, MULTI-LINE + VALUE + + # Plain-element comment + - &plainEntry Plain entry + """) + + yaml = YAML() + yaml.indent(mapping=2, sequence=4, offset=2) + yaml.explicit_start = True + yaml.preserve_quotes = True + yaml.width = sys.maxsize + data = yaml.load(yamldoc) + buf = StringIO() + yaml.dump(data, buf) + assert buf.getvalue() == yamldoc + # @pytest.mark.xfail(strict=True, reason='bla bla', raises=AssertionError) # def test_issue_ xxx(self): # inp = """ |