From 2c8fe012ef1ff6e0613480dd182dec099aa9636e Mon Sep 17 00:00:00 2001 From: Aron Xu Date: Sun, 9 Jun 2013 00:17:44 +0800 Subject: Imported Upstream version 2.9.1 --- python/tests/reader3.py | 63 ++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 29 deletions(-) (limited to 'python/tests/reader3.py') diff --git a/python/tests/reader3.py b/python/tests/reader3.py index 2458c89..4302b6c 100755 --- a/python/tests/reader3.py +++ b/python/tests/reader3.py @@ -3,8 +3,13 @@ # this tests the entities substitutions with the XmlTextReader interface # import sys -import StringIO import libxml2 +try: + import StringIO + str_io = StringIO.StringIO +except: + import io + str_io = io.StringIO docstr=""" """ def myResolver(URL, ID, ctxt): if URL == "simplestruct2.ent": - return(StringIO.StringIO(simplestruct2_ent)) + return(str_io(simplestruct2_ent)) return None libxml2.setEntityLoader(myResolver) -input = libxml2.inputBuffer(StringIO.StringIO(s)) +input = libxml2.inputBuffer(str_io(s)) reader = input.newTextReader("test3") reader.SetParserProp(libxml2.PARSER_SUBST_ENTITIES,1) while reader.Read() == 1: @@ -135,8 +140,8 @@ while reader.Read() == 1: reader.Depth(),reader.IsEmptyElement()) if res != expect: - print "test3 failed: unexpected output" - print res + print("test3 failed: unexpected output") + print(res) sys.exit(1) # @@ -149,7 +154,7 @@ del reader # Memory debug specific libxml2.cleanupParser() if libxml2.debugMemory(1) == 0: - print "OK" + print("OK") else: - print "Memory leak %d bytes" % (libxml2.debugMemory(1)) + print("Memory leak %d bytes" % (libxml2.debugMemory(1))) libxml2.dumpMemory() -- cgit v1.2.3