Skip to content

Commit fa17e16

Browse files
committed
[test/odmlparser] Add xml from_string test
1 parent 75aaadc commit fa17e16

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

test/test_parser_odml.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,27 @@ def test_rdf_file(self):
9797
# Check error on missing document format
9898
with self.assertRaises(ValueError):
9999
self.rdf_reader.from_file(self.rdf_file)
100+
101+
def test_xml_string(self):
102+
# Read from string
103+
author = "HPL"
104+
date = "1890-08-20"
105+
sec_name = "section name"
106+
sec_type = "section type"
107+
doc = """
108+
<odML version="1.1">
109+
<author>%s</author>
110+
<date>%s</date>
111+
<section>
112+
<name>%s</name>
113+
<type>%s</type>
114+
</section>
115+
</odML>
116+
""" % (author, date, sec_name, sec_type)
117+
118+
xml_doc = self.xml_reader.from_string(doc)
119+
120+
self.assertEqual(xml_doc.author, author)
121+
self.assertEqual(str(xml_doc.date), date)
122+
self.assertEqual(len(xml_doc.sections), 1)
123+
self.assertEqual(xml_doc.sections[0].name, sec_name)

0 commit comments

Comments
 (0)