3 # This test exercise the redirection of error messages with a
4 # functions defined in Python.
9 # Memory debug specific
10 libxml2.debugMemory(1)
12 expect="""--> (3) xmlns: URI foo is not absolute
13 --> (4) Opening and ending tag mismatch: x line 0 and y
17 def callback(arg,msg,severity,reserved):
19 err = err + "%s (%d) %s" % (arg,severity,msg)
21 s = """<x xmlns="foo"></y>"""
23 parserCtxt = libxml2.createPushParser(None,"",0,"test.xml")
24 parserCtxt.setErrorHandler(callback, "-->")
25 if parserCtxt.getErrorHandler() != (callback,"-->"):
26 print("getErrorHandler failed")
28 parserCtxt.parseChunk(s,len(s),1)
29 doc = parserCtxt.doc()
35 print("received %s" %(err))
36 print("expected %s" %(expect))
41 parserCtxt = libxml2.createPushParser(None,"",0,"test.xml")
42 parserCtxt.setErrorHandler(callback, "-->")
43 parserCtxt.parseChunk(s,len(s),1)
44 doc = parserCtxt.doc()
50 # Memory debug specific
51 libxml2.cleanupParser()
52 if libxml2.debugMemory(1) == 0:
55 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))