Commit 86e741dc authored by Stefan Behnel's avatar Stefan Behnel

go back to using StringIO for XML test reporter in Py2

parent 3d88f519
...@@ -44,8 +44,11 @@ import os ...@@ -44,8 +44,11 @@ import os
import sys import sys
import time import time
from unittest import TestResult, _TextTestResult, TextTestRunner from unittest import TestResult, _TextTestResult, TextTestRunner
from io import StringIO
import xml.dom.minidom import xml.dom.minidom
try:
from StringIO import StringIO
except ImportError:
from io import StringIO # doesn't accept 'str' in Py2
class XMLDocument(xml.dom.minidom.Document): class XMLDocument(xml.dom.minidom.Document):
...@@ -332,9 +335,10 @@ class _XMLTestResult(_TextTestResult): ...@@ -332,9 +335,10 @@ class _XMLTestResult(_TextTestResult):
class XMLTestRunner(TextTestRunner): class XMLTestRunner(TextTestRunner):
"""A test runner class that outputs the results in JUnit like XML files. """A test runner class that outputs the results in JUnit like XML files.
""" """
def __init__(self, output='.', stream=sys.stderr, descriptions=True, \ def __init__(self, output='.', stream=None, descriptions=True, verbose=False, elapsed_times=True):
verbose=False, elapsed_times=True):
"Create a new instance of XMLTestRunner." "Create a new instance of XMLTestRunner."
if stream is None:
stream = sys.stderr
verbosity = (1, 2)[verbose] verbosity = (1, 2)[verbose]
TextTestRunner.__init__(self, stream, descriptions, verbosity) TextTestRunner.__init__(self, stream, descriptions, verbosity)
self.output = output self.output = output
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment