VirtualBox

source: vbox/trunk/src/libs/libxml2-2.13.2/python/tests/error.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.0 KB
Line 
1#!/usr/bin/env python3
2#
3# This test exercise the redirection of error messages with a
4# functions defined in Python.
5#
6import sys
7import setup_test
8import libxml2
9
10# Memory debug specific
11libxml2.debugMemory(1)
12
13expect='--> I/O --> warning : --> failed to load "missing.xml": No such file or directory\n'
14err=""
15def callback(ctx, str):
16 global err
17
18 err = err + "%s %s" % (ctx, str)
19
20got_exc = 0
21libxml2.registerErrorHandler(callback, "-->")
22try:
23 doc = libxml2.parseFile("missing.xml")
24except libxml2.parserError:
25 got_exc = 1
26
27if got_exc == 0:
28 print("Failed to get a parser exception")
29 sys.exit(1)
30
31if err != expect:
32 print("error")
33 print("received %s" %(err))
34 print("expected %s" %(expect))
35 sys.exit(1)
36
37i = 10000
38while i > 0:
39 try:
40 doc = libxml2.parseFile("missing.xml")
41 except libxml2.parserError:
42 got_exc = 1
43 err = ""
44 i = i - 1
45
46# Memory debug specific
47libxml2.cleanupParser()
48if libxml2.debugMemory(1) == 0:
49 print("OK")
50else:
51 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