Skip to content
Snippets Groups Projects
Commit be261797 authored by Erik Arvidsson's avatar Erik Arvidsson
Browse files

Fix monkey yaml's handling of carriage return

monkeyYaml didn't split lines correctly leading to \r in resulting
values.

Fixes #295
parent 36cbdcf8
Branches
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ mYamlMultilineList = re.compile(r"^ *- (.*)$") ...@@ -16,7 +16,7 @@ mYamlMultilineList = re.compile(r"^ *- (.*)$")
def load(str): def load(str):
dict = None dict = None
lines = str.split("\n") lines = str.splitlines()
while lines: while lines:
line = lines.pop(0) line = lines.pop(0)
if myIsAllSpaces(line): if myIsAllSpaces(line):
......
...@@ -106,6 +106,10 @@ class TestMonkeyYAMLParsing(unittest.TestCase): ...@@ -106,6 +106,10 @@ class TestMonkeyYAMLParsing(unittest.TestCase):
self.assertEqual(lines, ["baz: bletch"]) self.assertEqual(lines, ["baz: bletch"])
self.assertEqual(value, ["foo", "bar"]) self.assertEqual(value, ["foo", "bar"])
def test_multiline_list_carriage_return(self):
y = "foo:\r\n - bar\r\n - baz"
self.assertEqual(monkeyYaml.load(y), yaml.load(y))
def test_oneline_indented(self): def test_oneline_indented(self):
y = " foo: bar\n baz: baf\n" y = " foo: bar\n baz: baf\n"
self.assertEqual(monkeyYaml.load(y), yaml.load(y)) self.assertEqual(monkeyYaml.load(y), yaml.load(y))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment