mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
xmlbuilder: Ensure top level XML objects always end with a newline
This commit is contained in:
parent
99a50de53e
commit
cb06f7eb3d
@ -171,7 +171,7 @@ class XMLParseTest(unittest.TestCase):
|
|||||||
rmfeat = guest.cpu.features[3]
|
rmfeat = guest.cpu.features[3]
|
||||||
guest.cpu.remove_feature(rmfeat)
|
guest.cpu.remove_feature(rmfeat)
|
||||||
self.assertEquals(rmfeat.get_xml_config(),
|
self.assertEquals(rmfeat.get_xml_config(),
|
||||||
"""<feature name="foo" policy="bar"/>""")
|
"""<feature name="foo" policy="bar"/>\n""")
|
||||||
guest.cpu.add_feature("addfeature")
|
guest.cpu.add_feature("addfeature")
|
||||||
|
|
||||||
check = self._make_checker(guest.numatune)
|
check = self._make_checker(guest.numatune)
|
||||||
@ -303,8 +303,8 @@ class XMLParseTest(unittest.TestCase):
|
|||||||
self._alter_compare(guest.get_xml_config(), outfile)
|
self._alter_compare(guest.get_xml_config(), outfile)
|
||||||
|
|
||||||
def testSingleDisk(self):
|
def testSingleDisk(self):
|
||||||
xml = ("""<disk type="file" device="disk"><source file="/a.img"/>"""
|
xml = ("""<disk type="file" device="disk"><source file="/a.img"/>\n"""
|
||||||
"""<target dev="hda" bus="ide"/></disk>""")
|
"""<target dev="hda" bus="ide"/></disk>\n""")
|
||||||
d = virtinst.VirtualDisk(conn, parsexml=xml)
|
d = virtinst.VirtualDisk(conn, parsexml=xml)
|
||||||
self._set_and_check(d, "target", "hda", "hdb")
|
self._set_and_check(d, "target", "hda", "hdb")
|
||||||
self.assertEquals(xml.replace("hda", "hdb"), d.get_xml_config())
|
self.assertEquals(xml.replace("hda", "hdb"), d.get_xml_config())
|
||||||
|
@ -1018,9 +1018,9 @@ class XMLBuilder(object):
|
|||||||
if ret == xmlstub:
|
if ret == xmlstub:
|
||||||
ret = ""
|
ret = ""
|
||||||
|
|
||||||
if (ret and
|
# Ensure top level XML object always ends with a newline, just
|
||||||
self._xmlstate.root_name == "domain" and
|
# for back compat and readability
|
||||||
not ret.endswith("\n")):
|
if (ret and not self.get_root_xpath() and not ret.endswith("\n")):
|
||||||
ret += "\n"
|
ret += "\n"
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user