diff options
author | Anthon van der Neut <anthon@mnt.org> | 2016-02-27 10:15:02 +0100 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2016-02-27 10:15:02 +0100 |
commit | 2f9cdc98cc0adea615cb2180481c7780eef48f97 (patch) | |
tree | ff710ad0913ced7c241f0445e95e6eefeb24ae1b /_test/roundtrip.py | |
parent | acc0b296466c5364569b1df8402d2cb95ca01915 (diff) | |
download | ruamel.yaml-2f9cdc98cc0adea615cb2180481c7780eef48f97.tar.gz |
pep8 compliance, util.load_yaml_guess_indent0.11.2
Diffstat (limited to '_test/roundtrip.py')
-rw-r--r-- | _test/roundtrip.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/_test/roundtrip.py b/_test/roundtrip.py index a8b0fb7..bd65c5a 100644 --- a/_test/roundtrip.py +++ b/_test/roundtrip.py @@ -22,33 +22,34 @@ def dedent(data): return textwrap.dedent(data) -def round_trip_load(dinp): +def round_trip_load(inp): + dinp = dedent(inp) return ruamel.yaml.load(dinp, ruamel.yaml.RoundTripLoader) def round_trip_dump(data, indent=None): dumper = ruamel.yaml.RoundTripDumper - return ruamel.yaml.dump(data, default_flow_style=False, Dumper=dumper, indent=indent) + return ruamel.yaml.dump(data, default_flow_style=False, Dumper=dumper, + allow_unicode=True, + indent=indent) -def round_trip(inp, outp=None, extra=None, intermediate=None): - dinp = dedent(inp) - if outp is not None: - doutp = dedent(outp) - else: - doutp = dinp +def round_trip(inp, outp=None, extra=None, intermediate=None, indent=None): + if outp is None: + outp = inp + doutp = dedent(outp) if extra is not None: doutp += extra - data = round_trip_load(dinp) + data = round_trip_load(inp) if intermediate is not None: if isinstance(intermediate, dict): for k, v in intermediate.items(): if data[k] != v: print('{0!r} <> {1!r}'.format(data[k], v)) raise ValueError - res = round_trip_dump(data) + res = round_trip_dump(data, indent=indent) print('roundtrip data:\n', res, sep='') assert res == doutp - res = round_trip_dump(data) + res = round_trip_dump(data, indent=indent) print('roundtrip second round data:\n', res, sep='') assert res == doutp |