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 TestMultiTestResult(TestWithFakeExceptions): """Tests for `MultiTestResult`.""" def setUp(self): TestWithFakeExceptions.setUp(self) self.result1 = LoggingResult([]) self.result2 = LoggingResult([]) self.multiResult = MultiTestResult(self.result1, self.result2) def assertResultLogsEqual(self, expectedEvents): """Assert that our test results have received the expected events.""" self.assertEqual(expectedEvents, self.result1._events) self.assertEqual(expectedEvents, self.result2._events) def test_empty(self): # Initializing a `MultiTestResult` doesn't do anything to its # `TestResult`s. self.assertResultLogsEqual([]) def test_startTest(self): # Calling `startTest` on a `MultiTestResult` calls `startTest` on all # its `TestResult`s. self.multiResult.startTest(self) self.assertResultLogsEqual([('startTest', self)]) def test_stopTest(self): # Calling `stopTest` on a `MultiTestResult` calls `stopTest` on all # its `TestResult`s. self.multiResult.stopTest(self) self.assertResultLogsEqual([('stopTest', self)]) def test_addSkipped(self): # Calling `addSkip` on a `MultiTestResult` calls addSkip on its # results. reason = _u("Skipped for some reason") self.multiResult.addSkip(self, reason) self.assertResultLogsEqual([('addSkip', self, reason)]) def test_addSuccess(self): # Calling `addSuccess` on a `MultiTestResult` calls `addSuccess` on # all its `TestResult`s. self.multiResult.addSuccess(self) self.assertResultLogsEqual([('addSuccess', self)]) def test_done(self): # Calling `done` on a `MultiTestResult` calls `done` on all its # `TestResult`s. self.multiResult.done() self.assertResultLogsEqual([('done')]) def test_addFailure(self): # Calling `addFailure` on a `MultiTestResult` calls `addFailure` on # all its `TestResult`s. exc_info = self.makeExceptionInfo(AssertionError, 'failure') self.multiResult.addFailure(self, exc_info) self.assertResultLogsEqual([('addFailure', self, exc_info)]) def test_addError(self): # Calling `addError` on a `MultiTestResult` calls `addError` on all # its `TestResult`s. exc_info = self.makeExceptionInfo(RuntimeError, 'error') self.multiResult.addError(self, exc_info) self.assertResultLogsEqual([('addError', self, exc_info)]) def test_startTestRun(self): # Calling `startTestRun` on a `MultiTestResult` forwards to all its # `TestResult`s. self.multiResult.startTestRun() self.assertResultLogsEqual([('startTestRun')]) def test_stopTestRun(self): # Calling `stopTestRun` on a `MultiTestResult` forwards to all its # `TestResult`s. 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) def test_time(self): # the time call is dispatched, not eaten by the base class self.multiResult.time('foo') self.assertResultLogsEqual([('time', 'foo')])
class TestMultiTestResult(TestWithFakeExceptions): """Tests for `MultiTestResult`.""" def setUp(self): TestWithFakeExceptions.setUp(self) self.result1 = LoggingResult([]) self.result2 = LoggingResult([]) self.multiResult = MultiTestResult(self.result1, self.result2) def assertResultLogsEqual(self, expectedEvents): """Assert that our test results have received the expected events.""" self.assertEqual(expectedEvents, self.result1._events) self.assertEqual(expectedEvents, self.result2._events) def test_empty(self): # Initializing a `MultiTestResult` doesn't do anything to its # `TestResult`s. self.assertResultLogsEqual([]) def test_startTest(self): # Calling `startTest` on a `MultiTestResult` calls `startTest` on all # its `TestResult`s. self.multiResult.startTest(self) self.assertResultLogsEqual([('startTest', self)]) def test_stopTest(self): # Calling `stopTest` on a `MultiTestResult` calls `stopTest` on all # its `TestResult`s. self.multiResult.stopTest(self) self.assertResultLogsEqual([('stopTest', self)]) def test_addSkipped(self): # Calling `addSkip` on a `MultiTestResult` calls addSkip on its # results. reason = _u("Skipped for some reason") self.multiResult.addSkip(self, reason) self.assertResultLogsEqual([('addSkip', self, reason)]) def test_addSuccess(self): # Calling `addSuccess` on a `MultiTestResult` calls `addSuccess` on # all its `TestResult`s. self.multiResult.addSuccess(self) self.assertResultLogsEqual([('addSuccess', self)]) def test_done(self): # Calling `done` on a `MultiTestResult` calls `done` on all its # `TestResult`s. self.multiResult.done() self.assertResultLogsEqual([('done')]) def test_addFailure(self): # Calling `addFailure` on a `MultiTestResult` calls `addFailure` on # all its `TestResult`s. exc_info = self.makeExceptionInfo(AssertionError, 'failure') self.multiResult.addFailure(self, exc_info) self.assertResultLogsEqual([('addFailure', self, exc_info)]) def test_addError(self): # Calling `addError` on a `MultiTestResult` calls `addError` on all # its `TestResult`s. exc_info = self.makeExceptionInfo(RuntimeError, 'error') self.multiResult.addError(self, exc_info) self.assertResultLogsEqual([('addError', self, exc_info)]) def test_startTestRun(self): # Calling `startTestRun` on a `MultiTestResult` forwards to all its # `TestResult`s. self.multiResult.startTestRun() self.assertResultLogsEqual([('startTestRun')]) def test_stopTestRun(self): # Calling `stopTestRun` on a `MultiTestResult` forwards to all its # `TestResult`s. self.multiResult.stopTestRun() self.assertResultLogsEqual([('stopTestRun')])
class TestMultiTestResult(TestWithFakeExceptions): """Tests for 'MultiTestResult'.""" def setUp(self): TestWithFakeExceptions.setUp(self) self.result1 = LoggingResult([]) self.result2 = LoggingResult([]) self.multiResult = MultiTestResult(self.result1, self.result2) def assertResultLogsEqual(self, expectedEvents): """Assert that our test results have received the expected events.""" self.assertEqual(expectedEvents, self.result1._events) self.assertEqual(expectedEvents, self.result2._events) def test_empty(self): # Initializing a `MultiTestResult` doesn't do anything to its # `TestResult`s. self.assertResultLogsEqual([]) def test_startTest(self): # Calling `startTest` on a `MultiTestResult` calls `startTest` on all # its `TestResult`s. self.multiResult.startTest(self) self.assertResultLogsEqual([('startTest', self)]) def test_stopTest(self): # Calling `stopTest` on a `MultiTestResult` calls `stopTest` on all # its `TestResult`s. self.multiResult.stopTest(self) self.assertResultLogsEqual([('stopTest', self)]) def test_addSkipped(self): # Calling `addSkip` on a `MultiTestResult` calls addSkip on its # results. reason = _u("Skipped for some reason") self.multiResult.addSkip(self, reason) self.assertResultLogsEqual([('addSkip', self, reason)]) def test_addSuccess(self): # Calling `addSuccess` on a `MultiTestResult` calls `addSuccess` on # all its `TestResult`s. self.multiResult.addSuccess(self) self.assertResultLogsEqual([('addSuccess', self)]) def test_done(self): # Calling `done` on a `MultiTestResult` calls `done` on all its # `TestResult`s. self.multiResult.done() self.assertResultLogsEqual([('done')]) def test_addFailure(self): # Calling `addFailure` on a `MultiTestResult` calls `addFailure` on # all its `TestResult`s. exc_info = self.makeExceptionInfo(AssertionError, 'failure') self.multiResult.addFailure(self, exc_info) self.assertResultLogsEqual([('addFailure', self, exc_info)]) def test_addError(self): # Calling `addError` on a `MultiTestResult` calls `addError` on all # its `TestResult`s. exc_info = self.makeExceptionInfo(RuntimeError, 'error') self.multiResult.addError(self, exc_info) self.assertResultLogsEqual([('addError', self, exc_info)]) def test_startTestRun(self): # Calling `startTestRun` on a `MultiTestResult` forwards to all its # `TestResult`s. self.multiResult.startTestRun() self.assertResultLogsEqual([('startTestRun')]) def test_stopTestRun(self): # Calling `stopTestRun` on a `MultiTestResult` forwards to all its # `TestResult`s. 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) def test_time(self): # the time call is dispatched, not eaten by the base class self.multiResult.time('foo') self.assertResultLogsEqual([('time', 'foo')])