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 gclient_scm.py.""" | 6 """Unit tests for gclient_scm.py.""" |
7 | 7 |
8 # Import before super_mox to keep valid references. | 8 # Import before super_mox to keep valid references. |
9 from os import rename | 9 from os import rename |
10 from shutil import rmtree | 10 from shutil import rmtree |
11 from subprocess import Popen, PIPE, STDOUT | 11 from subprocess import Popen, PIPE, STDOUT |
12 import tempfile | 12 import tempfile |
13 import __builtin__ | 13 import __builtin__ |
14 | 14 |
15 # Fixes include path. | 15 # Fixes include path. |
16 from super_mox import mox, SuperMoxBaseTestBase, SuperMoxTestBase | 16 from super_mox import mox, SuperMoxBaseTestBase, SuperMoxTestBase |
17 | 17 |
18 import gclient_scm | 18 import gclient_scm |
19 from gclient_test import BaseTestCase as GCBaseTestCase | 19 |
| 20 |
| 21 class GCBaseTestCase(SuperMoxTestBase): |
| 22 # Like unittest's assertRaises, but checks for Gclient.Error. |
| 23 def assertRaisesError(self, msg, fn, *args, **kwargs): |
| 24 try: |
| 25 fn(*args, **kwargs) |
| 26 except gclient_scm.gclient_utils.Error, e: |
| 27 self.assertEquals(e.args[0], msg) |
| 28 else: |
| 29 self.fail('%s not raised' % msg) |
20 | 30 |
21 | 31 |
22 class BaseTestCase(GCBaseTestCase): | 32 class BaseTestCase(GCBaseTestCase): |
23 def setUp(self): | 33 def setUp(self): |
24 GCBaseTestCase.setUp(self) | 34 GCBaseTestCase.setUp(self) |
25 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileRead') | 35 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileRead') |
26 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite') | 36 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite') |
27 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'SubprocessCall') | 37 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'SubprocessCall') |
28 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'RemoveDirectory') | 38 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'RemoveDirectory') |
29 self._CaptureSVNInfo = gclient_scm.scm.SVN.CaptureInfo | 39 self._CaptureSVNInfo = gclient_scm.scm.SVN.CaptureInfo |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 relpath=self.relpath) | 736 relpath=self.relpath) |
727 rev_info = scm.revinfo(options, (), None) | 737 rev_info = scm.revinfo(options, (), None) |
728 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') | 738 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') |
729 | 739 |
730 | 740 |
731 if __name__ == '__main__': | 741 if __name__ == '__main__': |
732 import unittest | 742 import unittest |
733 unittest.main() | 743 unittest.main() |
734 | 744 |
735 # vim: ts=2:sw=2:tw=80:et: | 745 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |