1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-17 18:21:05 +03:00

adding error redirections and preformat to a python handler cleanup made

* python/Makefile.am python/libxml.c python/libxml2-python-api.xml
  python/libxml2class.txt: adding error redirections and preformat
  to a python handler
* python/tests/Makefile.am python/tests/*.py: cleanup made all
  tests self checking
Daniel
This commit is contained in:
Daniel Veillard
2002-02-02 21:49:17 +00:00
parent 7fd7a94aa8
commit 5d81903b06
11 changed files with 184 additions and 28 deletions

View File

@ -1,29 +1,38 @@
#!/usr/bin/python -u
import sys
import libxml2
def foo(x):
# print "foo called %s" % (x)
return x + 1
def bar(x):
# print "foo called %s" % (x)
return "%s" % (x + 1)
return "%d" % (x + 2)
doc = libxml2.parseFile("tst.xml")
ctxt = doc.xpathNewContext()
res = ctxt.xpathEval("//*")
print res
if len(res) != 2:
print "xpath query: wrong node set size"
sys.exit(1)
if res[0].name != "doc" or res[1].name != "foo":
print "xpath query: wrong node set value"
sys.exit(1)
libxml2.registerXPathFunction(ctxt._o, "foo", None, foo)
libxml2.registerXPathFunction(ctxt._o, "bar", None, bar)
i = 10000
while i > 0:
res = ctxt.xpathEval("foo(1)")
if res != 2:
print "xpath extension failure"
sys.exit(1)
i = i - 1
print res
i = 10000
while i > 0:
res = ctxt.xpathEval("bar(1)")
if res != "3":
print "xpath extension failure got %s expecting '3'"
sys.exit(1)
i = i - 1
print res
doc.freeDoc()
print "OK"