You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2019/02/19 05:30:29 UTC
[impala] branch master updated: IMPALA-8193: Fix python 2.6 issue
in junit_prune_notrun.py
This is an automated email from the ASF dual-hosted git repository.
joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
The following commit(s) were added to refs/heads/master by this push:
new 4344914 IMPALA-8193: Fix python 2.6 issue in junit_prune_notrun.py
4344914 is described below
commit 4344914bb3da582d4ed7d73d08c8a274033b5430
Author: Joe McDonnell <jo...@cloudera.com>
AuthorDate: Wed Feb 13 12:06:24 2019 -0800
IMPALA-8193: Fix python 2.6 issue in junit_prune_notrun.py
Python 2.6's ElementTree.write() does not have an xml_declaration
argument, so junitxml_prune_notrun.py fails on python 2.6.
This fixes junitxml_prune_notrun.py by using minidom to write
the output. This mirrors how bin/generate_junitxml.py outputs
XML.
Verified that tests now pass on python 2.6 and python 2.7 does
not change.
Change-Id: I9ef8fb77b1ac8c51e3dfb6b04690ae9ccc490d62
Reviewed-on: http://gerrit.cloudera.org:8080/12479
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
lib/python/impala_py_lib/jenkins/junitxml_prune_notrun.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/python/impala_py_lib/jenkins/junitxml_prune_notrun.py b/lib/python/impala_py_lib/jenkins/junitxml_prune_notrun.py
index 9d9d921..98131a7 100755
--- a/lib/python/impala_py_lib/jenkins/junitxml_prune_notrun.py
+++ b/lib/python/impala_py_lib/jenkins/junitxml_prune_notrun.py
@@ -22,11 +22,12 @@ Some tests that produce JUnitXML include tests that did not run (i.e. status="no
This script walks through the JUnitXML and removes these elements.
"""
from optparse import OptionParser
-from xml.etree.ElementTree import ElementTree
+from xml.etree import ElementTree as ET
+from xml.dom import minidom
def junitxml_prune_notrun(junitxml_filename):
- tree = ElementTree()
+ tree = ET.ElementTree()
root = tree.parse(junitxml_filename)
for testsuite in root.findall("testsuite"):
@@ -52,7 +53,12 @@ def junitxml_prune_notrun(junitxml_filename):
# Fixup the total number of tests
testsuite.attrib["tests"] = str(num_tests - len(notrun_testcases))
# Write out the pruned JUnitXML
- tree.write(junitxml_filename, encoding="utf-8", xml_declaration=True)
+ # An XML declaration is optional, but it is nice to have. ElementTree.write() does
+ # not support an XML declaration on Python 2.6, so use minidom to write the XML.
+ root_node_minidom = minidom.parseString(ET.tostring(root))
+ junitxml_string = root_node_minidom.toxml(encoding="utf-8")
+ with open(junitxml_filename, "w") as f:
+ f.write(junitxml_string)
def main():