Last change
on this file since 107065 was 105420, checked in by vboxsync, 8 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.1 KB
|
Line | |
---|
1 | #!/usr/bin/env python3
|
---|
2 | #
|
---|
3 | # this tests the basic APIs of the XmlTextReader interface
|
---|
4 | #
|
---|
5 | import setup_test
|
---|
6 | import libxml2
|
---|
7 | import sys
|
---|
8 | try:
|
---|
9 | import StringIO
|
---|
10 | str_io = StringIO.StringIO
|
---|
11 | except:
|
---|
12 | import io
|
---|
13 | str_io = io.StringIO
|
---|
14 |
|
---|
15 | # Memory debug specific
|
---|
16 | libxml2.debugMemory(1)
|
---|
17 |
|
---|
18 | def tst_reader(s):
|
---|
19 | f = str_io(s)
|
---|
20 | input = libxml2.inputBuffer(f)
|
---|
21 | reader = input.newTextReader("tst")
|
---|
22 | res = ""
|
---|
23 | while reader.Read():
|
---|
24 | res=res + "%s (%s) [%s] %d\n" % (reader.NodeType(),reader.Name(),
|
---|
25 | reader.Value(), reader.IsEmptyElement())
|
---|
26 | if reader.NodeType() == 1: # Element
|
---|
27 | while reader.MoveToNextAttribute():
|
---|
28 | res = res + "-- %s (%s) [%s]\n" % (reader.NodeType(),
|
---|
29 | reader.Name(),reader.Value())
|
---|
30 | return res
|
---|
31 |
|
---|
32 | expect="""1 (test) [None] 0
|
---|
33 | 1 (b) [None] 1
|
---|
34 | 1 (c) [None] 1
|
---|
35 | 15 (test) [None] 0
|
---|
36 | """
|
---|
37 |
|
---|
38 | res = tst_reader("""<test><b/><c/></test>""")
|
---|
39 |
|
---|
40 | if res != expect:
|
---|
41 | print("Did not get the expected error message:")
|
---|
42 | print(res)
|
---|
43 | sys.exit(1)
|
---|
44 |
|
---|
45 | # Memory debug specific
|
---|
46 | libxml2.cleanupParser()
|
---|
47 | if libxml2.debugMemory(1) == 0:
|
---|
48 | print("OK")
|
---|
49 | else:
|
---|
50 | print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
|
---|
Note:
See
TracBrowser
for help on using the repository browser.