From 88d8880485e2e54c8fb3bb960bebd8f31d4a18f1 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Wed, 4 Aug 2010 15:59:32 +0100 Subject: [PATCH 1/3] Pass back the results we get. --- testtools/testresult/real.py | 5 +++-- testtools/tests/test_testresult.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/testtools/testresult/real.py b/testtools/testresult/real.py index 4ac66a6..3cae9fb 100644 --- a/testtools/testresult/real.py +++ b/testtools/testresult/real.py @@ -184,8 +184,9 @@ class MultiTestResult(TestResult): self._results = map(ExtendedToOriginalDecorator, results) def _dispatch(self, message, *args, **kwargs): - for result in self._results: + return tuple( getattr(result, message)(*args, **kwargs) + for result in self._results) def startTest(self, test): self._dispatch('startTest', test) @@ -215,7 +216,7 @@ class MultiTestResult(TestResult): self._dispatch('startTestRun') def stopTestRun(self): - self._dispatch('stopTestRun') + return self._dispatch('stopTestRun') def done(self): self._dispatch('done') diff --git a/testtools/tests/test_testresult.py b/testtools/tests/test_testresult.py index d7832b5..1a19440 100644 --- a/testtools/tests/test_testresult.py +++ b/testtools/tests/test_testresult.py @@ -264,6 +264,17 @@ class TestMultiTestResult(TestWithFakeExceptions): self.multiResult.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): """Tests for `TextTestResult`.""" From 683635a4d09741ea898e58359152f33d5694f922 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Wed, 4 Aug 2010 15:59:59 +0100 Subject: [PATCH 2/3] Cheat. Return the results of _dispatch always. --- testtools/testresult/real.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/testtools/testresult/real.py b/testtools/testresult/real.py index 3cae9fb..95f6e8f 100644 --- a/testtools/testresult/real.py +++ b/testtools/testresult/real.py @@ -189,37 +189,38 @@ class MultiTestResult(TestResult): for result in self._results) def startTest(self, test): - self._dispatch('startTest', test) + return self._dispatch('startTest', test) def stopTest(self, test): - self._dispatch('stopTest', test) + return self._dispatch('stopTest', test) 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): - self._dispatch('addExpectedFailure', test, err, details=details) + return self._dispatch( + 'addExpectedFailure', test, err, details=details) 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): - self._dispatch('addSkip', test, reason, details=details) + return self._dispatch('addSkip', test, reason, details=details) 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): - self._dispatch('addUnexpectedSuccess', test, details=details) + return self._dispatch('addUnexpectedSuccess', test, details=details) def startTestRun(self): - self._dispatch('startTestRun') + return self._dispatch('startTestRun') def stopTestRun(self): return self._dispatch('stopTestRun') def done(self): - self._dispatch('done') + return self._dispatch('done') class TextTestResult(TestResult): From 7791e4cb86365c54d63afbfe37f0151039a213e6 Mon Sep 17 00:00:00 2001 From: Jonathan Lange Date: Wed, 4 Aug 2010 16:01:47 +0100 Subject: [PATCH 3/3] NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index ca26368..222ca68 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,9 @@ Improvements * 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. + * MultiTestResult methods now pass back return values from the results it + forwards to. + 0.9.5 ~~~~~