'Assert that the given XML fragments have the same attributes, text, and
(recursively) children'

def assertXmlEqual(self, expected, xml):

    def get_child_tags(elem):
        'Extract    the    list    of    tag    names    for    children    of    elem'
        return [child.tag for child in elem]
    for attr in ['tag', 'attrib', 'text', 'tail']:
        self.assertEqual(getattr(expected, attr), getattr(xml, attr))
    self.assertEqual(get_child_tags(expected), get_child_tags(xml))
    for (left, right) in zip(expected, xml):
        self.assertXmlEqual(left, right)
