version 1.1.1.1, 2012/02/21 23:38:00
|
version 1.1.1.2, 2014/06/15 19:53:34
|
Line 27 ctxt = doc.xpathNewContext()
|
Line 27 ctxt = doc.xpathNewContext()
|
libxml2.registerXPathFunction(ctxt._o, "foo", None, foo) |
libxml2.registerXPathFunction(ctxt._o, "foo", None, foo) |
res = ctxt.xpathEval("foo('hello')") |
res = ctxt.xpathEval("foo('hello')") |
if type(res) != type([]): |
if type(res) != type([]): |
print "Failed to return a nodeset" | print("Failed to return a nodeset") |
sys.exit(1) |
sys.exit(1) |
if len(res) != 1: |
if len(res) != 1: |
print "Unexpected nodeset size" | print("Unexpected nodeset size") |
sys.exit(1) |
sys.exit(1) |
node = res[0] |
node = res[0] |
if node.name != 'p': |
if node.name != 'p': |
print "Unexpected nodeset element result" | print("Unexpected nodeset element result") |
sys.exit(1) |
sys.exit(1) |
node = node.children |
node = node.children |
if node.type != 'text': |
if node.type != 'text': |
print "Unexpected nodeset element children type" | print("Unexpected nodeset element children type") |
sys.exit(1) |
sys.exit(1) |
if node.content != 'hello': |
if node.content != 'hello': |
print "Unexpected nodeset element children content" | print("Unexpected nodeset element children content") |
sys.exit(1) |
sys.exit(1) |
|
|
doc.freeDoc() |
doc.freeDoc() |
Line 51 ctxt.xpathFreeContext()
|
Line 51 ctxt.xpathFreeContext()
|
#memory debug specific |
#memory debug specific |
libxml2.cleanupParser() |
libxml2.cleanupParser() |
if libxml2.debugMemory(1) == 0: |
if libxml2.debugMemory(1) == 0: |
print "OK" | print("OK") |
else: |
else: |
print "Memory leak %d bytes" % (libxml2.debugMemory(1)) | print("Memory leak %d bytes" % (libxml2.debugMemory(1))) |
libxml2.dumpMemory() |
libxml2.dumpMemory() |