changeset 696:f1a2831d549d

test: better ignore_blank in helpers's assertEqualXML
author Goffi <goffi@goffi.org>
date Tue, 12 Nov 2013 16:56:34 +0100
parents ddd2781bdd8c
children 0c84fb112d70
files src/test/helpers.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/test/helpers.py	Tue Nov 12 14:51:32 2013 +0100
+++ b/src/test/helpers.py	Tue Nov 12 16:56:34 2013 +0100
@@ -143,6 +143,15 @@
 
     def assertEqualXML(self, xml, expected, ignore_blank = False):
         def equalElt(got_elt, exp_elt):
+            if ignore_blank:
+                for elt in got_elt, exp_elt:
+                    for attr in ('text','tail'):
+                        value = getattr(elt, attr)
+                        try:
+                            value = value.strip() or None
+                        except AttributeError:
+                            value = None
+                        setattr(elt, attr, value)
             if (got_elt.tag != exp_elt.tag):
                 print "XML are not equals (elt %s/%s):" % (got_elt, exp_elt)
                 print "tag: got [%s] expected: [%s]" % (got_elt.tag, exp_elt.tag)