comparison 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
comparison
equal deleted inserted replaced
695:ddd2781bdd8c 696:f1a2831d549d
141 141
142 class SatTestCase(unittest.TestCase): 142 class SatTestCase(unittest.TestCase):
143 143
144 def assertEqualXML(self, xml, expected, ignore_blank = False): 144 def assertEqualXML(self, xml, expected, ignore_blank = False):
145 def equalElt(got_elt, exp_elt): 145 def equalElt(got_elt, exp_elt):
146 if ignore_blank:
147 for elt in got_elt, exp_elt:
148 for attr in ('text','tail'):
149 value = getattr(elt, attr)
150 try:
151 value = value.strip() or None
152 except AttributeError:
153 value = None
154 setattr(elt, attr, value)
146 if (got_elt.tag != exp_elt.tag): 155 if (got_elt.tag != exp_elt.tag):
147 print "XML are not equals (elt %s/%s):" % (got_elt, exp_elt) 156 print "XML are not equals (elt %s/%s):" % (got_elt, exp_elt)
148 print "tag: got [%s] expected: [%s]" % (got_elt.tag, exp_elt.tag) 157 print "tag: got [%s] expected: [%s]" % (got_elt.tag, exp_elt.tag)
149 return False 158 return False
150 if (got_elt.attrib != exp_elt.attrib): 159 if (got_elt.attrib != exp_elt.attrib):