]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Avoid using whitespace in test_safe_parse_xml.
authorJay S. Bryant <jsbryant@us.ibm.com>
Wed, 24 Apr 2013 17:56:03 +0000 (12:56 -0500)
committerJay S. Bryant <jsbryant@us.ibm.com>
Wed, 24 Apr 2013 18:02:38 +0000 (13:02 -0500)
Updates the test_safe_parse_xml test case in
cinder.tests.test_utils.GenericUtilsTestCase to avoid using
whitespaces and to ignore extraneous newlines returned in the
parsed XML.  This is required to work around differences in
the output from minidom in python 2.6.

Fixes LP Bug #1172352.

Change-Id: I48bdf3cb8eed3e65f7ceaeb1c2b19aa529c930d0

cinder/tests/test_utils.py

index 76aee6d1991e0643bf3a2f442afedb2f5aa6836c..c0de09dd49284c6314d27041704da400eca1689b 100644 (file)
@@ -428,13 +428,8 @@ class GenericUtilsTestCase(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>')
 
         def killer_body():
             return (("""<!DOCTYPE x [
@@ -453,7 +448,9 @@ class GenericUtilsTestCase(test.TestCase):
             }).strip()
 
         dom = utils.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(ValueError,
                           utils.safe_minidom_parse_string,