'Asserts that the xml tree has an element satisfying `xpath`.
`xml_root` is an etree XML element
`xpath` is an XPath string, such as `\'/foo/bar\'`
`context` is used to print a debugging message
`exact_num` is the exact number of matches to expect.'

def assert_has_xpath(self, xml_root, xpath, context_dict, exact_num=1):

    message = ("XML    does    not    have    %d    match(es)    for    xpath    '%s'\nXML:    %s\nContext:    %s" % (exact_num, str(xpath), etree.tostring(xml_root), str(context_dict)))
    self.assertEqual(len(xml_root.xpath(xpath)), exact_num, msg=message)
