Merge return-from-multitestresult.
This commit is contained in:
3
NEWS
3
NEWS
@@ -22,6 +22,9 @@ Improvements
|
|||||||
* TestCase now has a 'patch()' method to make it easier to monkey-patching
|
* TestCase now has a 'patch()' method to make it easier to monkey-patching
|
||||||
objects in tests. See the manual for more information. Fixes bug #310770.
|
objects in tests. See the manual for more information. Fixes bug #310770.
|
||||||
|
|
||||||
|
* MultiTestResult methods now pass back return values from the results it
|
||||||
|
forwards to.
|
||||||
|
|
||||||
0.9.5
|
0.9.5
|
||||||
~~~~~
|
~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -184,41 +184,43 @@ class MultiTestResult(TestResult):
|
|||||||
self._results = map(ExtendedToOriginalDecorator, results)
|
self._results = map(ExtendedToOriginalDecorator, results)
|
||||||
|
|
||||||
def _dispatch(self, message, *args, **kwargs):
|
def _dispatch(self, message, *args, **kwargs):
|
||||||
for result in self._results:
|
return tuple(
|
||||||
getattr(result, message)(*args, **kwargs)
|
getattr(result, message)(*args, **kwargs)
|
||||||
|
for result in self._results)
|
||||||
|
|
||||||
def startTest(self, test):
|
def startTest(self, test):
|
||||||
self._dispatch('startTest', test)
|
return self._dispatch('startTest', test)
|
||||||
|
|
||||||
def stopTest(self, test):
|
def stopTest(self, test):
|
||||||
self._dispatch('stopTest', test)
|
return self._dispatch('stopTest', test)
|
||||||
|
|
||||||
def addError(self, test, error=None, details=None):
|
def addError(self, test, error=None, details=None):
|
||||||
self._dispatch('addError', test, error, details=details)
|
return self._dispatch('addError', test, error, details=details)
|
||||||
|
|
||||||
def addExpectedFailure(self, test, err=None, details=None):
|
def addExpectedFailure(self, test, err=None, details=None):
|
||||||
self._dispatch('addExpectedFailure', test, err, details=details)
|
return self._dispatch(
|
||||||
|
'addExpectedFailure', test, err, details=details)
|
||||||
|
|
||||||
def addFailure(self, test, err=None, details=None):
|
def addFailure(self, test, err=None, details=None):
|
||||||
self._dispatch('addFailure', test, err, details=details)
|
return self._dispatch('addFailure', test, err, details=details)
|
||||||
|
|
||||||
def addSkip(self, test, reason=None, details=None):
|
def addSkip(self, test, reason=None, details=None):
|
||||||
self._dispatch('addSkip', test, reason, details=details)
|
return self._dispatch('addSkip', test, reason, details=details)
|
||||||
|
|
||||||
def addSuccess(self, test, details=None):
|
def addSuccess(self, test, details=None):
|
||||||
self._dispatch('addSuccess', test, details=details)
|
return self._dispatch('addSuccess', test, details=details)
|
||||||
|
|
||||||
def addUnexpectedSuccess(self, test, details=None):
|
def addUnexpectedSuccess(self, test, details=None):
|
||||||
self._dispatch('addUnexpectedSuccess', test, details=details)
|
return self._dispatch('addUnexpectedSuccess', test, details=details)
|
||||||
|
|
||||||
def startTestRun(self):
|
def startTestRun(self):
|
||||||
self._dispatch('startTestRun')
|
return self._dispatch('startTestRun')
|
||||||
|
|
||||||
def stopTestRun(self):
|
def stopTestRun(self):
|
||||||
self._dispatch('stopTestRun')
|
return self._dispatch('stopTestRun')
|
||||||
|
|
||||||
def done(self):
|
def done(self):
|
||||||
self._dispatch('done')
|
return self._dispatch('done')
|
||||||
|
|
||||||
|
|
||||||
class TextTestResult(TestResult):
|
class TextTestResult(TestResult):
|
||||||
|
|||||||
@@ -264,6 +264,17 @@ class TestMultiTestResult(TestWithFakeExceptions):
|
|||||||
self.multiResult.stopTestRun()
|
self.multiResult.stopTestRun()
|
||||||
self.assertResultLogsEqual([('stopTestRun')])
|
self.assertResultLogsEqual([('stopTestRun')])
|
||||||
|
|
||||||
|
def test_stopTestRun_returns_results(self):
|
||||||
|
# `MultiTestResult.stopTestRun` returns a tuple of all of the return
|
||||||
|
# values the `stopTestRun`s that it forwards to.
|
||||||
|
class Result(LoggingResult):
|
||||||
|
def stopTestRun(self):
|
||||||
|
super(Result, self).stopTestRun()
|
||||||
|
return 'foo'
|
||||||
|
multi_result = MultiTestResult(Result([]), Result([]))
|
||||||
|
result = multi_result.stopTestRun()
|
||||||
|
self.assertEqual(('foo', 'foo'), result)
|
||||||
|
|
||||||
|
|
||||||
class TestTextTestResult(TestCase):
|
class TestTextTestResult(TestCase):
|
||||||
"""Tests for `TextTestResult`."""
|
"""Tests for `TextTestResult`."""
|
||||||
|
|||||||
Reference in New Issue
Block a user