Commit ff823e5d authored by da-woods's avatar da-woods Committed by Stefan Behnel

Import TextTestResult in test runner instead of _TextTestResult (GH-4415)

All the versions we currently test are new enough that the alias is no longer necessary.
parent 889c6f19
...@@ -43,7 +43,7 @@ from __future__ import absolute_import ...@@ -43,7 +43,7 @@ from __future__ import absolute_import
import os import os
import sys import sys
import time import time
from unittest import TestResult, _TextTestResult, TextTestRunner from unittest import TestResult, TextTestResult, TextTestRunner
import xml.dom.minidom import xml.dom.minidom
try: try:
from StringIO import StringIO from StringIO import StringIO
...@@ -95,7 +95,7 @@ class _TestInfo(object): ...@@ -95,7 +95,7 @@ class _TestInfo(object):
self.err, self.test_method) self.err, self.test_method)
class _XMLTestResult(_TextTestResult): class _XMLTestResult(TextTestResult):
"""A test result class that can express test results in a XML report. """A test result class that can express test results in a XML report.
Used by XMLTestRunner. Used by XMLTestRunner.
...@@ -103,7 +103,7 @@ class _XMLTestResult(_TextTestResult): ...@@ -103,7 +103,7 @@ class _XMLTestResult(_TextTestResult):
def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1, def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1,
elapsed_times=True): elapsed_times=True):
"Create a new instance of _XMLTestResult." "Create a new instance of _XMLTestResult."
_TextTestResult.__init__(self, stream, descriptions, verbosity) TextTestResult.__init__(self, stream, descriptions, verbosity)
self.successes = [] self.successes = []
self.callback = None self.callback = None
self.elapsed_times = elapsed_times self.elapsed_times = elapsed_times
...@@ -159,7 +159,7 @@ class _XMLTestResult(_TextTestResult): ...@@ -159,7 +159,7 @@ class _XMLTestResult(_TextTestResult):
def stopTest(self, test): def stopTest(self, test):
"Called after execute each test method." "Called after execute each test method."
self._restore_standard_output() self._restore_standard_output()
_TextTestResult.stopTest(self, test) TextTestResult.stopTest(self, test)
self.stop_time = time.time() self.stop_time = time.time()
if self.callback and callable(self.callback): if self.callback and callable(self.callback):
......
...@@ -1433,14 +1433,11 @@ class _FakeClass(object): ...@@ -1433,14 +1433,11 @@ class _FakeClass(object):
def shortDescription(self): def shortDescription(self):
return self._shortDescription return self._shortDescription
try: # Py2.7+ and Py3.2+ from unittest import TextTestResult
from unittest.runner import _TextTestResult
except ImportError:
from unittest import _TextTestResult
class PartialTestResult(_TextTestResult): class PartialTestResult(TextTestResult):
def __init__(self, base_result): def __init__(self, base_result):
_TextTestResult.__init__( TextTestResult.__init__(
self, self._StringIO(), True, self, self._StringIO(), True,
base_result.dots + base_result.showAll*2) base_result.dots + base_result.showAll*2)
try: try:
......
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