| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import collections | 5 import collections |
| 6 import inspect | 6 import inspect |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 | 9 |
| 10 class AutoStubMixIn(object): | 10 class AutoStubMixIn(object): |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 str_kwargs = ', '.join('%s=%r' % (k, v) for k, v in kwargs.iteritems()) | 61 str_kwargs = ', '.join('%s=%r' % (k, v) for k, v in kwargs.iteritems()) |
| 62 self.calls.append('%s(%s)' % ( | 62 self.calls.append('%s(%s)' % ( |
| 63 caller_name, ', '.join(filter(None, [str_args, str_kwargs])))) | 63 caller_name, ', '.join(filter(None, [str_args, str_kwargs])))) |
| 64 | 64 |
| 65 | 65 |
| 66 class TestCase(unittest.TestCase, AutoStubMixIn): | 66 class TestCase(unittest.TestCase, AutoStubMixIn): |
| 67 """Adds self.mock() and self.has_failed() to a TestCase.""" | 67 """Adds self.mock() and self.has_failed() to a TestCase.""" |
| 68 def tearDown(self): | 68 def tearDown(self): |
| 69 AutoStubMixIn.tearDown(self) | 69 AutoStubMixIn.tearDown(self) |
| 70 unittest.TestCase.tearDown(self) | 70 unittest.TestCase.tearDown(self) |
| 71 | |
| 72 def has_failed(self): | |
| 73 """Returns True if the test has failed.""" | |
| 74 return not self._resultForDoCleanups.wasSuccessful() | |
| OLD | NEW |