5 # Memory debug specific
11 def startDocument(self):
13 log = log + "startDocument:"
15 def endDocument(self):
17 log = log + "endDocument:"
19 def startElement(self, tag, attrs):
21 log = log + "startElement %s %s:" % (tag, attrs)
23 def endElement(self, tag):
25 log = log + "endElement %s:" % (tag)
27 def characters(self, data):
29 log = log + "characters: %s:" % (data)
31 def warning(self, msg):
33 log = log + "warning: %s:" % (msg)
37 log = log + "error: %s:" % (msg)
39 def fatalError(self, msg):
41 log = log + "fatalError: %s:" % (msg)
45 ctxt = libxml2.createPushParser(handler, "<foo", 4, "test.xml")
46 chunk = " url='tst'>b"
47 ctxt.parseChunk(chunk, len(chunk), 0)
49 ctxt.parseChunk(chunk, len(chunk), 1)
52 reference = "startDocument:startElement foo {'url': 'tst'}:characters: bar:endElement foo:endDocument:"
54 print "Error got: %s" % log
55 print "Exprected: %s" % reference
58 # Memory debug specific
59 libxml2.cleanupParser()
60 if libxml2.debugMemory(1) == 0:
63 print "Memory leak %d bytes" % (libxml2.debugMemory(1))