def test8(self): expr = Compile("/bla:one") l = expr(self.test_doc_ns, self.env) count = 0 for n in l: count += 1 self.assert_(n.tagName == "one") self.assert_(count == 1)
def test7(self): expr = Compile("/one/two/*") l = expr(self.test_doc, Environment()) count = 0 for n in l: count += 1 self.assert_(n.tagName == "three") self.assert_(count == 3)
def test13(self): expr = Compile("/one/s:two") l = expr(self.test_doc_ns, self.env) count = 0 for n in l: count += 1 self.assert_(n.tagName == "sss:two") self.assert_(count == 1)
def test9(self): expr = Compile("/level1/level2[level3][1]") l = list(expr(self.test_doc, Environment())) self.assert_(len(l) == 1) self.assert_(all(l, lambda n: n.tagName == "level2"))
def test8(self): expr = Compile("/level1/level2[3][2]") l = list(expr(self.test_doc, Environment())) self.assert_(len(l) == 0)
def test7(self): expr = Compile("/level1/level2[3][1]") l = list(expr(self.test_doc, Environment())) self.assert_(len(l) == 1) self.assert_(l[0].getAttribute("id") == "3")
def __init__(self, expression, reference) : self.xpath = Compile(expression)
def test3(self): expr = Compile("/one") l = expr(self.test_doc, Environment()) root = l.next() self.assert_(root == self.test_doc.documentElement)
def test1(self): expr = Compile("/") l = expr(self.test_doc, Environment()) root = l.next() self.assert_(root == self.test_doc)
def runTest(self): if self.test_doc: self.test_doc = parseString(self.test_doc) expr = Compile(self.test_string) self.assert_(expr(self.test_doc, Environment()) == self.result)