mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-11 05:17:59 +03: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]
|
||||
guest.cpu.remove_feature(rmfeat)
|
||||
self.assertEquals(rmfeat.get_xml_config(),
|
||||
"""<feature name="foo" policy="bar"/>""")
|
||||
"""<feature name="foo" policy="bar"/>\n""")
|
||||
guest.cpu.add_feature("addfeature")
|
||||
|
||||
check = self._make_checker(guest.numatune)
|
||||
@ -303,8 +303,8 @@ class XMLParseTest(unittest.TestCase):
|
||||
self._alter_compare(guest.get_xml_config(), outfile)
|
||||
|
||||
def testSingleDisk(self):
|
||||
xml = ("""<disk type="file" device="disk"><source file="/a.img"/>"""
|
||||
"""<target dev="hda" bus="ide"/></disk>""")
|
||||
xml = ("""<disk type="file" device="disk"><source file="/a.img"/>\n"""
|
||||
"""<target dev="hda" bus="ide"/></disk>\n""")
|
||||
d = virtinst.VirtualDisk(conn, parsexml=xml)
|
||||
self._set_and_check(d, "target", "hda", "hdb")
|
||||
self.assertEquals(xml.replace("hda", "hdb"), d.get_xml_config())
|
||||
|
@ -1018,9 +1018,9 @@ class XMLBuilder(object):
|
||||
if ret == xmlstub:
|
||||
ret = ""
|
||||
|
||||
if (ret and
|
||||
self._xmlstate.root_name == "domain" and
|
||||
not ret.endswith("\n")):
|
||||
# Ensure top level XML object always ends with a newline, just
|
||||
# for back compat and readability
|
||||
if (ret and not self.get_root_xpath() and not ret.endswith("\n")):
|
||||
ret += "\n"
|
||||
return ret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user