OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 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 re | 6 import re |
7 import StringIO | 7 import StringIO |
8 | 8 |
9 import gclient_utils | 9 import gclient_utils |
10 from super_mox import SuperMoxTestBase | 10 from super_mox import SuperMoxTestBase |
(...skipping 14 matching lines...) Expand all Loading... |
25 self.compareMembers(gclient_utils, members) | 25 self.compareMembers(gclient_utils, members) |
26 | 26 |
27 | 27 |
28 class CheckCallTestCase(SuperMoxTestBase): | 28 class CheckCallTestCase(SuperMoxTestBase): |
29 def testCheckCallSuccess(self): | 29 def testCheckCallSuccess(self): |
30 command = ['boo', 'foo', 'bar'] | 30 command = ['boo', 'foo', 'bar'] |
31 process = self.mox.CreateMockAnything() | 31 process = self.mox.CreateMockAnything() |
32 process.returncode = 0 | 32 process.returncode = 0 |
33 gclient_utils.subprocess.Popen( | 33 gclient_utils.subprocess.Popen( |
34 command, cwd=None, | 34 command, cwd=None, |
| 35 stderr=None, |
35 stdout=gclient_utils.subprocess.PIPE, | 36 stdout=gclient_utils.subprocess.PIPE, |
36 shell=gclient_utils.sys.platform.startswith('win')).AndReturn(process) | 37 shell=gclient_utils.sys.platform.startswith('win')).AndReturn(process) |
37 process.communicate().AndReturn(['bleh']) | 38 process.communicate().AndReturn(['bleh']) |
38 self.mox.ReplayAll() | 39 self.mox.ReplayAll() |
39 gclient_utils.CheckCall(command) | 40 gclient_utils.CheckCall(command) |
40 | 41 |
41 def testCheckCallFailure(self): | 42 def testCheckCallFailure(self): |
42 command = ['boo', 'foo', 'bar'] | 43 command = ['boo', 'foo', 'bar'] |
43 process = self.mox.CreateMockAnything() | 44 process = self.mox.CreateMockAnything() |
44 process.returncode = 42 | 45 process.returncode = 42 |
45 gclient_utils.subprocess.Popen( | 46 gclient_utils.subprocess.Popen( |
46 command, cwd=None, | 47 command, cwd=None, |
| 48 stderr=None, |
47 stdout=gclient_utils.subprocess.PIPE, | 49 stdout=gclient_utils.subprocess.PIPE, |
48 shell=gclient_utils.sys.platform.startswith('win')).AndReturn(process) | 50 shell=gclient_utils.sys.platform.startswith('win')).AndReturn(process) |
49 process.communicate().AndReturn(['bleh']) | 51 process.communicate().AndReturn(['bleh']) |
50 self.mox.ReplayAll() | 52 self.mox.ReplayAll() |
51 try: | 53 try: |
52 gclient_utils.CheckCall(command) | 54 gclient_utils.CheckCall(command) |
53 self.fail() | 55 self.fail() |
54 except gclient_utils.CheckCallError, e: | 56 except gclient_utils.CheckCallError, e: |
55 self.assertEqual(e.command, command) | 57 self.assertEqual(e.command, command) |
56 self.assertEqual(e.cwd, None) | 58 self.assertEqual(e.cwd, None) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 base_url = 'svn://a/b/c/d' | 147 base_url = 'svn://a/b/c/d' |
146 full_url = gclient_utils.FullUrlFromRelative2(base_url, '/crap') | 148 full_url = gclient_utils.FullUrlFromRelative2(base_url, '/crap') |
147 self.assertEqual(full_url, 'svn://a/b/c/crap') | 149 self.assertEqual(full_url, 'svn://a/b/c/crap') |
148 | 150 |
149 | 151 |
150 if __name__ == '__main__': | 152 if __name__ == '__main__': |
151 import unittest | 153 import unittest |
152 unittest.main() | 154 unittest.main() |
153 | 155 |
154 # vim: ts=2:sw=2:tw=80:et: | 156 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |