Avoid using whitespace in test_safe_parse_xml.
Updates our MiscellaneousXMLUtilTests.test_safe_parse_xml test so that it avoids using and ignores whitespace. This works around some minidom parsing differences that can happen with some versions of python 2.6. Fixes LP Bug #1158826. Change-Id: Iada0b095ab3b5ac6dc026b3ff6cdfb175f1e20a7
This commit is contained in:
@@ -726,16 +726,13 @@ class MiscellaneousXMLUtilTests(test.TestCase):
|
|||||||
|
|
||||||
def test_safe_parse_xml(self):
|
def test_safe_parse_xml(self):
|
||||||
|
|
||||||
normal_body = ("""
|
normal_body = ('<?xml version="1.0" ?>'
|
||||||
<?xml version="1.0" ?><foo>
|
'<foo><bar><v1>hey</v1><v2>there</v2></bar></foo>')
|
||||||
<bar>
|
|
||||||
<v1>hey</v1>
|
|
||||||
<v2>there</v2>
|
|
||||||
</bar>
|
|
||||||
</foo>""").strip()
|
|
||||||
|
|
||||||
dom = xmlutil.safe_minidom_parse_string(normal_body)
|
dom = xmlutil.safe_minidom_parse_string(normal_body)
|
||||||
self.assertEqual(normal_body, str(dom.toxml()))
|
# Some versions of minidom inject extra newlines so we ignore them
|
||||||
|
result = str(dom.toxml()).replace('\n', '')
|
||||||
|
self.assertEqual(normal_body, result)
|
||||||
|
|
||||||
self.assertRaises(exception.MalformedRequestBody,
|
self.assertRaises(exception.MalformedRequestBody,
|
||||||
xmlutil.safe_minidom_parse_string,
|
xmlutil.safe_minidom_parse_string,
|
||||||
|
|||||||
Reference in New Issue
Block a user