VirtualBox

source: vbox/trunk/src/libs/libxml2-2.12.6/python/tests/resolver.py@ 105132

最後變更 在這個檔案從105132是 104106,由 vboxsync 提交於 12 月 前

libxml2-2.9.14: Applied and adjusted our libxml2 changes to 2.9.14. bugref:10640

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:executable 設為 *
檔案大小: 852 位元組
 
1#!/usr/bin/env python3
2import sys
3import setup_test
4import libxml2
5try:
6 import StringIO
7 str_io = StringIO.StringIO
8except:
9 import io
10 str_io = io.StringIO
11
12# Memory debug specific
13libxml2.debugMemory(1)
14
15def myResolver(URL, ID, ctxt):
16 return(str_io("<foo/>"))
17
18libxml2.setEntityLoader(myResolver)
19
20doc = libxml2.parseFile("doesnotexist.xml")
21root = doc.children
22if root.name != "foo":
23 print("root element name error")
24 sys.exit(1)
25doc.freeDoc()
26
27i = 0
28while i < 5000:
29 doc = libxml2.parseFile("doesnotexist.xml")
30 root = doc.children
31 if root.name != "foo":
32 print("root element name error")
33 sys.exit(1)
34 doc.freeDoc()
35 i = i + 1
36
37
38# Memory debug specific
39libxml2.cleanupParser()
40if libxml2.debugMemory(1) == 0:
41 print("OK")
42else:
43 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
44
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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