VirtualBox

source: vbox/trunk/src/libs/libxml2-2.13.2/python/tests/pushSAXhtml.py@ 105420

Last change on this file since 105420 was 105420, checked in by vboxsync, 7 months ago

libxml2-2.12.6: Applied and adjusted our libxml2 changes to 2.12.6. bugref:10730

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