def setUp(self): self.test_doc = parseString(test_doc) self.test_doc_ns = parseString(test_doc_ns) self.env = Environment(nsMap={ "bla": "http://blablabla/a_namepace", "s": "http://sss.org///?sss" })
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 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 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)