VirtualBox

source: vbox/trunk/src/libs/libxml2-2.13.2/python/tests/build.py

Last change on this file 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.5 KB
Line 
1#!/usr/bin/env python3
2import setup_test
3import libxml2
4import sys
5
6# Memory debug specific
7libxml2.debugMemory(1)
8
9doc = libxml2.newDoc("1.0")
10comment = doc.newDocComment("This is a generated document")
11doc.addChild(comment)
12pi = libxml2.newPI("test", "PI content")
13doc.addChild(pi)
14root = doc.newChild(None, "doc", None)
15ns = root.newNs("http://example.com/doc", "my")
16root.setNs(ns)
17elem = root.newChild(None, "foo", "bar")
18elem.setBase("http://example.com/imgs")
19elem.setProp("img", "image.gif")
20doc.saveFile("tmp.xml")
21doc.freeDoc()
22
23doc = libxml2.parseFile("tmp.xml")
24comment = doc.children
25if comment.type != "comment" or \
26 comment.content != "This is a generated document":
27 print("error rereading comment")
28 sys.exit(1)
29pi = comment.next
30if pi.type != "pi" or pi.name != "test" or pi.content != "PI content":
31 print("error rereading PI")
32 sys.exit(1)
33root = pi.next
34if root.name != "doc":
35 print("error rereading root")
36 sys.exit(1)
37ns = root.ns()
38if ns.name != "my" or ns.content != "http://example.com/doc":
39 print("error rereading namespace")
40 sys.exit(1)
41elem = root.children
42if elem.name != "foo":
43 print("error rereading elem")
44 sys.exit(1)
45if elem.getBase(None) != "http://example.com/imgs":
46 print("error rereading base")
47 sys.exit(1)
48if elem.prop("img") != "image.gif":
49 print("error rereading property")
50 sys.exit(1)
51
52doc.freeDoc()
53
54# Memory debug specific
55libxml2.cleanupParser()
56if libxml2.debugMemory(1) == 0:
57 print("OK")
58else:
59 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