Chromium Code Reviews| Index: testing_support/tests/thread_watcher_test.py |
| diff --git a/testing_support/tests/thread_watcher_test.py b/testing_support/tests/thread_watcher_test.py |
| index 4989f2d8311a5625b9b4c84ef36e9bff95057875..d1aa12076985cbb1ed6f3ece2fc8527419e2cdf7 100644 |
| --- a/testing_support/tests/thread_watcher_test.py |
| +++ b/testing_support/tests/thread_watcher_test.py |
| @@ -28,6 +28,13 @@ class _PuppetThread(threading.Thread): |
| self._stop_event.set() |
| self.join() |
| +class _ResultFake(object): |
| + def __init__(self, value): |
| + self.value = value |
| + |
| + def wasSuccessful(self): |
| + return self.value |
| + |
| class ThreadWatcherTestCase(thread_watcher.TestCase): |
| def setUp(self): |
| @@ -71,6 +78,38 @@ class ThreadWatcherTestCase(thread_watcher.TestCase): |
| self.assertNotIn(' Thread stopped while acquiring stacktrace.\n', |
| error_message) |
| + def test_extra_threads_unittest_pass(self): |
| + # Test succeeded, so thread_watcher must cause failure. |
| + self.watcher._resultForDoCleanups = _ResultFake(True) |
| + self.watcher.setUp() |
| + self._threads.append(_PuppetThread('foo')) |
| + self.watcher.tearDown() |
| + self.assertEqual(len(self._fail_called), 1) |
| + |
| + def test_extra_threads_unittest_pass(self): |
|
Michael Achenbach
2016/07/07 12:30:41
Same method signature as the method above? Also th
tandrii(chromium)
2016/07/07 12:56:39
Done.
|
| + # Test failed already, so thread_watcher must ignore result. |
| + self.watcher._resultForDoCleanups = _ResultFake(False) |
| + self.watcher.setUp() |
| + self._threads.append(_PuppetThread('foo')) |
| + self.watcher.tearDown() |
| + self.assertEqual(self._fail_called, []) |
| + |
| + def test_extra_threads_expect_tests_pass(self): |
| + # Test succeeded, so thread_watcher must cause failure. |
| + self.watcher._test_failed_with_exception = False |
| + self.watcher.setUp() |
| + self._threads.append(_PuppetThread('foo')) |
| + self.watcher.tearDown() |
| + self.assertEqual(len(self._fail_called), 1) |
| + |
| + def test_extra_threads_expect_tests_pass(self): |
| + # Test failed already, so thread_watcher must ignore result. |
| + self.watcher._test_failed_with_exception = True |
| + self.watcher.setUp() |
| + self._threads.append(_PuppetThread('foo')) |
| + self.watcher.tearDown() |
| + self.assertEqual(self._fail_called, []) |
| + |
| def test_fail_get_stacktrace(self): |
| self.watcher.setUp() |
| self._threads.append(_PuppetThread('foo')) |