Make subunit2html.py python2.6 compatible.

* modules/jenkins/files/slave_scripts/subunit2html.py: Swap out unittest
with testtools for python 2.6 compatibility. Remove argparse and
manually parse argv for python 2.6 compatibility.

Change-Id: If3a253439550b5394b9b7eac129d8ed66b7ba951
Reviewed-on: https://review.openstack.org/26785
Reviewed-by: lifeless <robertc@robertcollins.net>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: Monty Taylor <mordred@inaugust.com>
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Tested-by: Jenkins
This commit is contained in:
Clark Boylan 2013-04-11 13:12:19 -07:00 committed by Jenkins
parent bc6848e7de
commit e3852213b0

View File

@ -39,12 +39,11 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
import argparse
import collections
import datetime
import io
import sys
import traceback
import unittest
from xml.sax import saxutils
import subunit
@ -442,7 +441,7 @@ class ClassInfoWrapper(object):
return "%s" % (self.name)
class HtmlOutput(unittest.TestResult):
class HtmlOutput(testtools.TestResult):
"""Output test results in html."""
def __init__(self, html_file='result.html'):
@ -709,15 +708,17 @@ class FileAccumulator(testtools.StreamResult):
def main():
parser = argparse.ArgumentParser()
parser.add_argument("subunit_file",
help="Path to input subunit file.")
parser.add_argument("html_file",
help="Path to output html file.")
args = parser.parse_args()
if len(sys.argv) < 2:
print "Need at least one argument: path to subunit log."
exit(1)
subunit_file = sys.argv[1]
if len(sys.argv) > 2:
html_file = sys.argv[2]
else:
html_file = 'results.html'
html_result = HtmlOutput(args.html_file)
stream = open(args.subunit_file, 'rb')
html_result = HtmlOutput(html_file)
stream = open(subunit_file, 'rb')
# Feed the subunit stream through both a V1 and V2 parser.
# Depends on having the v2 capable libraries installed.