diff options
author | Anthon van der Neut <anthon@mnt.org> | 2016-04-14 15:52:40 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2016-04-14 15:52:40 +0200 |
commit | 879d6d4e99f31436e2a9a9aed84c96817e766431 (patch) | |
tree | f34316628998e6e5ee83908e7387ab5b896f42dc /_test | |
parent | 9fd5fa35ed5aae678af14f2dbeed8f1a06e775b0 (diff) | |
download | ruamel.yaml-879d6d4e99f31436e2a9a9aed84c96817e766431.tar.gz |
added top_level_colon_align/prefix_colon0.11.9
Diffstat (limited to '_test')
-rw-r--r-- | _test/roundtrip.py | 21 | ||||
-rw-r--r-- | _test/test_indentation.py | 20 |
2 files changed, 33 insertions, 8 deletions
diff --git a/_test/roundtrip.py b/_test/roundtrip.py index 4534a16..b9cc657 100644 --- a/_test/roundtrip.py +++ b/_test/roundtrip.py @@ -27,15 +27,16 @@ def round_trip_load(inp): return ruamel.yaml.load(dinp, ruamel.yaml.RoundTripLoader) -def round_trip_dump(data, indent=None, block_seq_indent=None): - dumper = ruamel.yaml.RoundTripDumper - return ruamel.yaml.dump(data, default_flow_style=False, Dumper=dumper, - allow_unicode=True, - indent=indent, block_seq_indent=block_seq_indent) +def round_trip_dump(data, indent=None, block_seq_indent=None, top_level_colon_align=None, + prefix_colon=None): + return ruamel.yaml.round_trip_dump(data, + indent=indent, block_seq_indent=block_seq_indent, + top_level_colon_align=top_level_colon_align, + prefix_colon=prefix_colon) def round_trip(inp, outp=None, extra=None, intermediate=None, indent=None, - block_seq_indent=None): + block_seq_indent=None, top_level_colon_align=None, prefix_colon=None): if outp is None: outp = inp doutp = dedent(outp) @@ -48,9 +49,13 @@ def round_trip(inp, outp=None, extra=None, intermediate=None, indent=None, if data[k] != v: print('{0!r} <> {1!r}'.format(data[k], v)) raise ValueError - res = round_trip_dump(data, indent=indent, block_seq_indent=block_seq_indent) + res = round_trip_dump(data, indent=indent, block_seq_indent=block_seq_indent, + top_level_colon_align=top_level_colon_align, + prefix_colon=prefix_colon) print('roundtrip data:\n', res, sep='') assert res == doutp - res = round_trip_dump(data, indent=indent, block_seq_indent=block_seq_indent) + res = round_trip_dump(data, indent=indent, block_seq_indent=block_seq_indent, + top_level_colon_align=top_level_colon_align, + prefix_colon=prefix_colon) print('roundtrip second round data:\n', res, sep='') assert res == doutp diff --git a/_test/test_indentation.py b/_test/test_indentation.py index 41f7ae9..954f231 100644 --- a/_test/test_indentation.py +++ b/_test/test_indentation.py @@ -151,6 +151,26 @@ class TestIndent: """, indent=2, block_seq_indent=2) +class TestYpkgIndent: + def test_00(self): + round_trip(""" + name : nano + version : 2.3.2 + release : 1 + homepage : http://www.nano-editor.org + source : + - http://www.nano-editor.org/dist/v2.3/nano-2.3.2.tar.gz : ff309248071486445609ad4269b798262a1324d7503dc09dea289f5b60106be8 + license : GPL-2.0 + summary : GNU nano is an easy-to-use text editor + builddeps : + - ncurses-devel + description: | + GNU nano is an easy-to-use text editor originally designed + as a replacement for Pico, the ncurses-based editor from the non-free mailer + package Pine (itself now available under the Apache License as Alpine). + """, indent=4, block_seq_indent=2, top_level_colon_align=True, prefix_colon=' ') + + def guess(s): x, y, z = load_yaml_guess_indent(dedent(s)) return y, z |