VirtualBox

source: vbox/trunk/src/libs/libxml2-2.6.30/python/tests/pushSAXhtml.py@ 11632

Last change on this file since 11632 was 6076, checked in by vboxsync, 17 years ago

Merged dmik/s2 branch (r25959:26751) to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 1.6 KB
Line 
1#!/usr/bin/python -u
2import sys
3import libxml2
4
5# Memory debug specific
6libxml2.debugMemory(1)
7
8log = ""
9
10class callback:
11 def startDocument(self):
12 global log
13 log = log + "startDocument:"
14
15 def endDocument(self):
16 global log
17 log = log + "endDocument:"
18
19 def startElement(self, tag, attrs):
20 global log
21 log = log + "startElement %s %s:" % (tag, attrs)
22
23 def endElement(self, tag):
24 global log
25 log = log + "endElement %s:" % (tag)
26
27 def characters(self, data):
28 global log
29 log = log + "characters: %s:" % (data)
30
31 def warning(self, msg):
32 global log
33 log = log + "warning: %s:" % (msg)
34
35 def error(self, msg):
36 global log
37 log = log + "error: %s:" % (msg)
38
39 def fatalError(self, msg):
40 global log
41 log = log + "fatalError: %s:" % (msg)
42
43handler = callback()
44
45ctxt = libxml2.htmlCreatePushParser(handler, "<foo", 4, "test.xml")
46chunk = " url='tst'>b"
47ctxt.htmlParseChunk(chunk, len(chunk), 0)
48chunk = "ar</foo>"
49ctxt.htmlParseChunk(chunk, len(chunk), 1)
50ctxt=None
51
52reference = """startDocument:startElement html None:startElement body None:startElement foo {'url': 'tst'}:error: Tag foo invalid
53:characters: bar:endElement foo:endElement body:endElement html:endDocument:"""
54if log != reference:
55 print "Error got: %s" % log
56 print "Exprected: %s" % reference
57 sys.exit(1)
58
59# Memory debug specific
60libxml2.cleanupParser()
61if libxml2.debugMemory(1) == 0:
62 print "OK"
63else:
64 print "Memory leak %d bytes" % (libxml2.debugMemory(1))
65 libxml2.dumpMemory()
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette