def test_xpath_compile_ns(self): x = self.parse('<a><b xmlns="nsa"/><b xmlns="nsb"/></a>') expr = etree.ETXPath("/a/{nsa}b") r = expr(x) self.assertEquals(1, len(r)) self.assertEquals('{nsa}b', r[0].tag) expr = etree.ETXPath("/a/{nsb}b") r = expr(x) self.assertEquals(1, len(r)) self.assertEquals('{nsb}b', r[0].tag)
def _test_xpath_compile_unicode(self): x = self.parse(_bytes('<a><b xmlns="http://nsa/\\uf8d2"/><b xmlns="http://nsb/\\uf8d1"/></a>' ).decode("unicode_escape")) expr = etree.ETXPath(_bytes("/a/{http://nsa/\\uf8d2}b").decode("unicode_escape")) r = expr(x) self.assertEquals(1, len(r)) self.assertEquals(_bytes('{http://nsa/\\uf8d2}b').decode("unicode_escape"), r[0].tag) expr = etree.ETXPath(_bytes("/a/{http://nsb/\\uf8d1}b").decode("unicode_escape")) r = expr(x) self.assertEquals(1, len(r)) self.assertEquals(_bytes('{http://nsb/\\uf8d1}b').decode("unicode_escape"), r[0].tag)