diff --git a/tests/p_libxml2-python/0-install-libxml2-python.sh b/tests/p_libxml2-python/0-install-libxml2-python.sh index 6e2b2a2..edf9dec 100755 --- a/tests/p_libxml2-python/0-install-libxml2-python.sh +++ b/tests/p_libxml2-python/0-install-libxml2-python.sh @@ -4,4 +4,8 @@ # Install libxml2-python t_Log "Running $0 - installing libxml2-python." +if [ "$centos_ver" -ge 8 ] ; then +t_InstallPackage python3-libxml2 +else t_InstallPackage libxml2-python +fi diff --git a/tests/p_libxml2-python/1-test-XmlTextReader.sh b/tests/p_libxml2-python/1-test-XmlTextReader.sh index f873255..d040b17 100755 --- a/tests/p_libxml2-python/1-test-XmlTextReader.sh +++ b/tests/p_libxml2-python/1-test-XmlTextReader.sh @@ -4,13 +4,22 @@ t_Log "Running $0 - test XmlTextReader of libxml2-python" -cat << 'EOF' | python - | grep -q 'test succeeded' +if [ "$centos_ver" -ge 8 ] ; then +PYTHON=python3 +else +PYTHON=python +fi + +cat << 'EOF' | $PYTHON - | grep -q 'test succeeded' import libxml2 import sys -import StringIO +try: + from StringIO import StringIO +except ImportError: + from io import StringIO # Load a small xml structure -xmlStr = StringIO.StringIO(""" +xmlStr = StringIO(""" val1val2""") xmlBuf = libxml2.inputBuffer(xmlStr) xmlReader = xmlBuf.newTextReader("reader") @@ -45,5 +54,5 @@ checkRead(xmlReader, "key2", 0, 15, 0) checkRead(xmlReader, "key3", 1, 1, 0) checkRead(xmlReader, "test", 0, 15, 1) checkRead(xmlReader, "tests", 0, 15, 0) -print "test succeeded" +print ("test succeeded") EOF