VirtualBox

source: vbox/trunk/src/libs/libxml2-2.9.4/python/tests/error.py@ 76389

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

libxml 2.9.4: fix export

  • 屬性 svn:eol-style 設為 LF
  • 屬性 svn:executable 設為 *
檔案大小: 1.0 KB
 
1#!/usr/bin/python -u
2#
3# This test exercise the redirection of error messages with a
4# functions defined in Python.
5#
6import sys
7import libxml2
8
9# Memory debug specific
10libxml2.debugMemory(1)
11
12expect='--> I/O --> warning : --> failed to load external entity "missing.xml"\n'
13err=""
14def callback(ctx, str):
15 global err
16
17 err = err + "%s %s" % (ctx, str)
18
19got_exc = 0
20libxml2.registerErrorHandler(callback, "-->")
21try:
22 doc = libxml2.parseFile("missing.xml")
23except libxml2.parserError:
24 got_exc = 1
25
26if got_exc == 0:
27 print("Failed to get a parser exception")
28 sys.exit(1)
29
30if err != expect:
31 print("error")
32 print("received %s" %(err))
33 print("expected %s" %(expect))
34 sys.exit(1)
35
36i = 10000
37while i > 0:
38 try:
39 doc = libxml2.parseFile("missing.xml")
40 except libxml2.parserError:
41 got_exc = 1
42 err = ""
43 i = i - 1
44
45# Memory debug specific
46libxml2.cleanupParser()
47if libxml2.debugMemory(1) == 0:
48 print("OK")
49else:
50 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
51 libxml2.dumpMemory()
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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