Skip to content

Commit c91bd8b

Browse files
committed
[test] Add fileio xml kwarg tests
1 parent cfc9a58 commit c91bd8b

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

test/test_fileio.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ def test_load_save(self):
2727
odml.save(doc, file_name)
2828
os.remove(file_name)
2929

30+
def test_save_kwargs(self):
31+
doc = odml.load(self.file)
32+
file_name = "%s_copy" % self.file
33+
34+
# Test unsupported kwarg does not raise an exception
35+
odml.save(doc, file_name, unsupported_kwarg="I do not matter")
36+
os.remove(file_name)
37+
3038
def test_display(self):
3139
doc = odml.load(self.file)
3240
odml.display(doc)

test/test_parser_odml.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,39 @@ def test_xml_file(self):
6868

6969
self.assertEqual(xml_doc, self.odml_doc)
7070

71+
def test_xml_file_kwargs(self):
72+
# Check unsupported kwargs
73+
self.xml_writer.write_file(self.odml_doc, self.xml_file,
74+
invalid_a=False, invalid_b=None, invalid_c="naughty")
75+
xml_doc = self.xml_reader.from_file(self.xml_file)
76+
77+
self.assertEqual(xml_doc, self.odml_doc)
78+
79+
# Check invalid local_style
80+
self.xml_writer.write_file(self.odml_doc, self.xml_file, local_style="this is not good")
81+
xml_doc = self.xml_reader.from_file(self.xml_file)
82+
83+
self.assertEqual(xml_doc, self.odml_doc)
84+
85+
# Check valid local_style
86+
self.xml_writer.write_file(self.odml_doc, self.xml_file, local_style=True)
87+
xml_doc = self.xml_reader.from_file(self.xml_file)
88+
89+
self.assertEqual(xml_doc, self.odml_doc)
90+
91+
# Check invalid custom template
92+
self.xml_writer.write_file(self.odml_doc, self.xml_file, custom_template=True)
93+
xml_doc = self.xml_reader.from_file(self.xml_file)
94+
95+
self.assertEqual(xml_doc, self.odml_doc)
96+
97+
# Check custom template
98+
custom = "<xsl:template></xsl:template>"
99+
self.xml_writer.write_file(self.odml_doc, self.xml_file, custom_template=custom)
100+
xml_doc = self.xml_reader.from_file(self.xml_file)
101+
102+
self.assertEqual(xml_doc, self.odml_doc)
103+
71104
def test_yaml_file(self):
72105
self.yaml_writer.write_file(self.odml_doc, self.yaml_file)
73106
yaml_doc = self.yaml_reader.from_file(self.yaml_file)

0 commit comments

Comments
 (0)