diff src/test/helpers.py @ 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 4284b6ad8aa3
children bfabeedbf32e
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)