Fix monkey yaml's handling of carriage return

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

Fixes #295
This commit is contained in:
Erik Arvidsson 2015-06-10 10:30:55 -04:00
parent 36cbdcf8ec
commit be26179719
2 changed files with 5 additions and 1 deletions

View File

@ -16,7 +16,7 @@ mYamlMultilineList = re.compile(r"^ *- (.*)$")
def load(str):
dict = None
lines = str.split("\n")
lines = str.splitlines()
while lines:
line = lines.pop(0)
if myIsAllSpaces(line):

View File

@ -106,6 +106,10 @@ class TestMonkeyYAMLParsing(unittest.TestCase):
self.assertEqual(lines, ["baz: bletch"])
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):
y = " foo: bar\n baz: baf\n"
self.assertEqual(monkeyYaml.load(y), yaml.load(y))