summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2016-09-04 14:01:20 +0200
committerAnthon van der Neut <anthon@mnt.org>2016-09-04 14:01:20 +0200
commitd8662dcf14f3a2a7ee1035830144edf6d94dc1bc (patch)
tree82e24ce1cba3948c291ff7d51f22b744476fd04c /_test
parent3f7dc0c35e67f1435ba708921f88f075db824034 (diff)
downloadruamel.yaml-d8662dcf14f3a2a7ee1035830144edf6d94dc1bc.tar.gz
fix issue 54: space on empty lines break roundtrip0.12.7
Diffstat (limited to '_test')
-rw-r--r--_test/test_comments.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/_test/test_comments.py b/_test/test_comments.py
index 4bdaed1..63895cc 100644
--- a/_test/test_comments.py
+++ b/_test/test_comments.py
@@ -569,3 +569,25 @@ class TestEmptyLines:
- 3
""")
+
+ def test_line_with_only_spaces(self):
+ # issue 54
+ yaml_str = "---\n\na: 'x'\n \nb: y\n"
+ d = round_trip_load(yaml_str, preserve_quotes=True)
+ y = round_trip_dump(d, explicit_start=True)
+ stripped = ""
+ for line in yaml_str.splitlines():
+ stripped += line.rstrip() + '\n'
+ print(line + '$')
+ assert stripped == y
+
+ def test_some_eol_spaces(self):
+ # spaces after tokens and on empty lines
+ yaml_str = '--- \n \na: "x" \n \nb: y \n'
+ d = round_trip_load(yaml_str, preserve_quotes=True)
+ y = round_trip_dump(d, explicit_start=True)
+ stripped = ""
+ for line in yaml_str.splitlines():
+ stripped += line.rstrip() + '\n'
+ print(line + '$')
+ assert stripped == y