VirtualBox

source: vbox/trunk/src/libs/libxml2-2.9.4/python/tests/build.py@ 71370

最後變更 在這個檔案從71370是 65950,由 vboxsync 提交於 8 年 前

libxml 2.9.4: fix export

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:executable 設為 *
檔案大小: 1.5 KB
 
1#!/usr/bin/python -u
2import libxml2
3import sys
4
5# Memory debug specific
6libxml2.debugMemory(1)
7
8doc = libxml2.newDoc("1.0")
9comment = doc.newDocComment("This is a generated document")
10doc.addChild(comment)
11pi = libxml2.newPI("test", "PI content")
12doc.addChild(pi)
13root = doc.newChild(None, "doc", None)
14ns = root.newNs("http://example.com/doc", "my")
15root.setNs(ns)
16elem = root.newChild(None, "foo", "bar")
17elem.setBase("http://example.com/imgs")
18elem.setProp("img", "image.gif")
19doc.saveFile("tmp.xml")
20doc.freeDoc()
21
22doc = libxml2.parseFile("tmp.xml")
23comment = doc.children
24if comment.type != "comment" or \
25 comment.content != "This is a generated document":
26 print("error rereading comment")
27 sys.exit(1)
28pi = comment.next
29if pi.type != "pi" or pi.name != "test" or pi.content != "PI content":
30 print("error rereading PI")
31 sys.exit(1)
32root = pi.next
33if root.name != "doc":
34 print("error rereading root")
35 sys.exit(1)
36ns = root.ns()
37if ns.name != "my" or ns.content != "http://example.com/doc":
38 print("error rereading namespace")
39 sys.exit(1)
40elem = root.children
41if elem.name != "foo":
42 print("error rereading elem")
43 sys.exit(1)
44if elem.getBase(None) != "http://example.com/imgs":
45 print("error rereading base")
46 sys.exit(1)
47if elem.prop("img") != "image.gif":
48 print("error rereading property")
49 sys.exit(1)
50
51doc.freeDoc()
52
53# Memory debug specific
54libxml2.cleanupParser()
55if libxml2.debugMemory(1) == 0:
56 print("OK")
57else:
58 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
59 libxml2.dumpMemory()
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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