OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for scm.py.""" | 6 """Unit tests for scm.py.""" |
7 | 7 |
8 from shutil import rmtree | 8 from shutil import rmtree |
9 import tempfile | 9 import tempfile |
10 | 10 |
11 # Fixes include path. | 11 # Fixes include path. |
12 from super_mox import mox, SuperMoxBaseTestBase | 12 from super_mox import mox, SuperMoxBaseTestBase, SuperMoxTestBase |
13 | 13 |
14 from gclient_test import BaseTestCase | |
15 import scm | 14 import scm |
16 | 15 |
17 | 16 |
| 17 class BaseTestCase(SuperMoxTestBase): |
| 18 # Like unittest's assertRaises, but checks for Gclient.Error. |
| 19 def assertRaisesError(self, msg, fn, *args, **kwargs): |
| 20 try: |
| 21 fn(*args, **kwargs) |
| 22 except scm.gclient_utils.Error, e: |
| 23 self.assertEquals(e.args[0], msg) |
| 24 else: |
| 25 self.fail('%s not raised' % msg) |
| 26 |
| 27 |
18 class BaseSCMTestCase(BaseTestCase): | 28 class BaseSCMTestCase(BaseTestCase): |
19 def setUp(self): | 29 def setUp(self): |
20 BaseTestCase.setUp(self) | 30 BaseTestCase.setUp(self) |
21 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCall') | 31 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCall') |
22 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCallAndFilter') | 32 self.mox.StubOutWithMock(scm.gclient_utils, 'SubprocessCallAndFilter') |
23 | 33 |
24 | 34 |
25 class RootTestCase(BaseSCMTestCase): | 35 class RootTestCase(BaseSCMTestCase): |
26 def testMembersChanged(self): | 36 def testMembersChanged(self): |
27 self.mox.ReplayAll() | 37 self.mox.ReplayAll() |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 self.mox.ReplayAll() | 337 self.mox.ReplayAll() |
328 info = scm.SVN.CaptureStatus(None) | 338 info = scm.SVN.CaptureStatus(None) |
329 self.assertEquals(info, []) | 339 self.assertEquals(info, []) |
330 | 340 |
331 | 341 |
332 if __name__ == '__main__': | 342 if __name__ == '__main__': |
333 import unittest | 343 import unittest |
334 unittest.main() | 344 unittest.main() |
335 | 345 |
336 # vim: ts=2:sw=2:tw=80:et: | 346 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |