| 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 import StringIO | 6 import StringIO |
| 7 | 7 |
| 8 # Fixes include path. | 8 # Fixes include path. |
| 9 from super_mox import SuperMoxTestBase | 9 from super_mox import SuperMoxTestBase |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 # If this test fails, you should add the relevant test. | 36 # If this test fails, you should add the relevant test. |
| 37 self.compareMembers(gclient_utils, members) | 37 self.compareMembers(gclient_utils, members) |
| 38 | 38 |
| 39 | 39 |
| 40 class CheckCallTestCase(GclientUtilBase): | 40 class CheckCallTestCase(GclientUtilBase): |
| 41 def testCheckCallSuccess(self): | 41 def testCheckCallSuccess(self): |
| 42 args = ['boo', 'foo', 'bar'] | 42 args = ['boo', 'foo', 'bar'] |
| 43 process = self.mox.CreateMockAnything() | 43 process = self.mox.CreateMockAnything() |
| 44 process.returncode = 0 | 44 process.returncode = 0 |
| 45 gclient_utils.Popen( | 45 gclient_utils.Popen( |
| 46 args, cwd=None, | 46 args, cwd='bar', |
| 47 stderr=None, | 47 stderr=None, |
| 48 stdout=gclient_utils.subprocess.PIPE).AndReturn(process) | 48 stdout=gclient_utils.subprocess.PIPE).AndReturn(process) |
| 49 process.communicate().AndReturn(['bleh', 'foo']) | 49 process.communicate().AndReturn(['bleh', 'foo']) |
| 50 self.mox.ReplayAll() | 50 self.mox.ReplayAll() |
| 51 gclient_utils.CheckCall(args) | 51 gclient_utils.CheckCall(args, cwd='bar') |
| 52 | 52 |
| 53 def testCheckCallFailure(self): | 53 def testCheckCallFailure(self): |
| 54 args = ['boo', 'foo', 'bar'] | 54 args = ['boo', 'foo', 'bar'] |
| 55 process = self.mox.CreateMockAnything() | 55 process = self.mox.CreateMockAnything() |
| 56 process.returncode = 42 | 56 process.returncode = 42 |
| 57 gclient_utils.Popen( | 57 gclient_utils.Popen( |
| 58 args, cwd=None, | 58 args, |
| 59 stderr=None, | 59 stderr=None, |
| 60 stdout=gclient_utils.subprocess.PIPE).AndReturn(process) | 60 stdout=gclient_utils.subprocess.PIPE).AndReturn(process) |
| 61 process.communicate().AndReturn(['bleh', 'foo']) | 61 process.communicate().AndReturn(['bleh', 'foo']) |
| 62 self.mox.ReplayAll() | 62 self.mox.ReplayAll() |
| 63 try: | 63 try: |
| 64 gclient_utils.CheckCall(args) | 64 gclient_utils.CheckCall(args) |
| 65 self.fail() | 65 self.fail() |
| 66 except gclient_utils.CheckCallError, e: | 66 except gclient_utils.CheckCallError, e: |
| 67 self.assertEqual(e.command, args) | 67 self.assertEqual(e.command, args) |
| 68 self.assertEqual(e.cwd, None) | 68 self.assertEqual(e.cwd, None) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 out_url, out_rev = gclient_utils.SplitUrlRevision("%s@%s" % (url, rev)) | 162 out_url, out_rev = gclient_utils.SplitUrlRevision("%s@%s" % (url, rev)) |
| 163 self.assertEquals(out_rev, rev) | 163 self.assertEquals(out_rev, rev) |
| 164 self.assertEquals(out_url, url) | 164 self.assertEquals(out_url, url) |
| 165 | 165 |
| 166 | 166 |
| 167 if __name__ == '__main__': | 167 if __name__ == '__main__': |
| 168 import unittest | 168 import unittest |
| 169 unittest.main() | 169 unittest.main() |
| 170 | 170 |
| 171 # vim: ts=2:sw=2:tw=80:et: | 171 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |