Skip to content

Commit 1945a45

Browse files
committed
[test/odmlparser] Add yaml from_string test
1 parent ba1be52 commit 1945a45

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

test/test_parser_odml.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,25 @@ def test_json_string(self):
150150

151151
# Test empty return on broken json document
152152
self.assertIsNone(self.json_reader.from_string("{"))
153+
154+
def test_yaml_string(self):
155+
author = "HPL"
156+
date = "1890-08-20"
157+
sec_name = "section name"
158+
sec_type = "section type"
159+
yaml_doc = """
160+
odml-version: '1.1'
161+
Document:
162+
author: %s
163+
date: %s
164+
sections:
165+
- name: %s
166+
type: %s
167+
""" % (author, date, sec_name, sec_type)
168+
169+
ydoc = self.yaml_reader.from_string(yaml_doc)
170+
171+
self.assertEqual(ydoc.author, author)
172+
self.assertEqual(str(ydoc.date), date)
173+
self.assertEqual(len(ydoc.sections), 1)
174+
self.assertEqual(ydoc.sections[0].name, sec_name)

0 commit comments

Comments
 (0)