Commit f325bfd0 authored by Julien Muchembled's avatar Julien Muchembled

Fix backportUnittest for Python 2.7.4

parent ee2edadb
...@@ -179,9 +179,12 @@ class TestCase(unittest.TestCase): ...@@ -179,9 +179,12 @@ class TestCase(unittest.TestCase):
def defaultTestResult(self): def defaultTestResult(self):
return TestResult() return TestResult()
class TestResult(unittest.TestResult): if not hasattr(unittest.TestResult, 'addSkip'): # BBB: Python < 2.7
unittest.TestResult._orig_init__ = unittest.TestResult.__init__.im_func
def __init__(self): def __init__(self):
super(TestResult, self).__init__() self._orig_init__()
self.skipped = [] self.skipped = []
self.expectedFailures = [] self.expectedFailures = []
self.unexpectedSuccesses = [] self.unexpectedSuccesses = []
...@@ -199,13 +202,10 @@ class TestResult(unittest.TestResult): ...@@ -199,13 +202,10 @@ class TestResult(unittest.TestResult):
"""Called when a test was expected to fail, but succeed.""" """Called when a test was expected to fail, but succeed."""
self.unexpectedSuccesses.append(test) self.unexpectedSuccesses.append(test)
for f in __init__, addSkip, addExpectedFailure, addUnexpectedSuccess:
setattr(unittest.TestResult, f.__name__, f)
class _TextTestResult(unittest._TextTestResult, TestResult): class _TextTestResult(unittest._TextTestResult):
def __init__(self, stream, descriptions, verbosity):
# BACK: nice diamond!
# unittest.TestResult.__init__ is called twice here
unittest._TextTestResult.__init__(self, stream, descriptions, verbosity)
TestResult.__init__(self)
def wasSuccessful(self): def wasSuccessful(self):
"Tells whether or not this result was a success" "Tells whether or not this result was a success"
......
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