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