summaryrefslogtreecommitdiff
path: root/python/tests/error.py
blob: 21cf5589e888038ae33277bd7df3ca12ec7fb68a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python -u
#
# This test exercise the redirection of error messages with a
# functions defined in Python.
#
import sys
import libxml2

expect='--> warning: --> failed to load external entity "missing.xml"\n'
err=""
def callback(ctx, str):
     global err

     err = err + "%s %s" % (ctx, str)

libxml2.registerErrorHandler(callback, "-->")
doc = libxml2.parseFile("missing.xml")
if err != expect:
    print "error"
    print "received %s" %(err)
    print "expected %s" %(expect)
    sys.exit(1)

i = 10000
while i > 0:
    doc = libxml2.parseFile("missing.xml")
    err = ""
    i = i - 1

print "OK"