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:
Dan Prince
2013-03-23 08:28:14 -04:00
parent 2d02ce3ba0
commit cff0ae1cd9

View File

@@ -726,16 +726,13 @@ class MiscellaneousXMLUtilTests(test.TestCase):
def test_safe_parse_xml(self):
normal_body = ("""
<?xml version="1.0" ?><foo>
<bar>
<v1>hey</v1>
<v2>there</v2>
</bar>
</foo>""").strip()
normal_body = ('<?xml version="1.0" ?>'
'<foo><bar><v1>hey</v1><v2>there</v2></bar></foo>')
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,
xmlutil.safe_minidom_parse_string,