5 # Memory debug specific
14 doc = libxml2.parseFile("tst.xml")
15 ctxt = doc.xpathNewContext()
16 res = ctxt.xpathEval("//*")
18 print("xpath query: wrong node set size")
20 if res[0].name != "doc" or res[1].name != "foo":
21 print("xpath query: wrong node set value")
24 libxml2.registerXPathFunction(ctxt._o, "foo", None, foo)
25 libxml2.registerXPathFunction(ctxt._o, "bar", None, bar)
28 res = ctxt.xpathEval("foo(1)")
30 print("xpath extension failure")
35 res = ctxt.xpathEval("bar(1)")
37 print("xpath extension failure got %s expecting '3'")
41 ctxt.xpathFreeContext()
43 # Memory debug specific
44 libxml2.cleanupParser()
45 if libxml2.debugMemory(1) == 0:
48 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))