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 # pylint: disable=E1101,W0403 |
| 7 |
6 import StringIO | 8 import StringIO |
7 | 9 |
8 # Fixes include path. | 10 # Fixes include path. |
9 from super_mox import SuperMoxTestBase | 11 from super_mox import SuperMoxTestBase |
10 | 12 |
11 import gclient_utils | 13 import gclient_utils |
12 | 14 |
13 | 15 |
14 class GclientUtilBase(SuperMoxTestBase): | 16 class GclientUtilBase(SuperMoxTestBase): |
15 def setUp(self): | 17 def setUp(self): |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 self.assertEqual(e.returncode, 42) | 71 self.assertEqual(e.returncode, 42) |
70 self.assertEqual(e.stdout, 'bleh') | 72 self.assertEqual(e.stdout, 'bleh') |
71 self.assertEqual(e.stderr, 'foo') | 73 self.assertEqual(e.stderr, 'foo') |
72 | 74 |
73 | 75 |
74 class CheckCallAndFilterTestCase(GclientUtilBase): | 76 class CheckCallAndFilterTestCase(GclientUtilBase): |
75 class ProcessIdMock(object): | 77 class ProcessIdMock(object): |
76 def __init__(self, test_string): | 78 def __init__(self, test_string): |
77 self.stdout = StringIO.StringIO(test_string) | 79 self.stdout = StringIO.StringIO(test_string) |
78 def wait(self): | 80 def wait(self): |
79 pass | 81 pass |
80 | 82 |
81 def _inner(self, args, test_string): | 83 def _inner(self, args, test_string): |
82 cwd = 'bleh' | 84 cwd = 'bleh' |
83 gclient_utils.sys.stdout.write( | 85 gclient_utils.sys.stdout.write( |
84 '\n________ running \'boo foo bar\' in \'bleh\'\n') | 86 '\n________ running \'boo foo bar\' in \'bleh\'\n') |
85 for i in test_string: | 87 for i in test_string: |
86 gclient_utils.sys.stdout.write(i) | 88 gclient_utils.sys.stdout.write(i) |
87 gclient_utils.Popen( | 89 gclient_utils.Popen( |
88 args, | 90 args, |
89 cwd=cwd, | 91 cwd=cwd, |
(...skipping 15 matching lines...) Expand all Loading... |
105 args, cwd=cwd, always=True, filter_fn=FilterLines) | 107 args, cwd=cwd, always=True, filter_fn=FilterLines) |
106 self.assertEquals(line_list, ['ahah', 'accb', 'allo', 'addb']) | 108 self.assertEquals(line_list, ['ahah', 'accb', 'allo', 'addb']) |
107 self.assertEquals(capture_list, ['cc', 'dd']) | 109 self.assertEquals(capture_list, ['cc', 'dd']) |
108 | 110 |
109 def testCheckCallAndFilter(self): | 111 def testCheckCallAndFilter(self): |
110 args = ['boo', 'foo', 'bar'] | 112 args = ['boo', 'foo', 'bar'] |
111 test_string = 'ahah\naccb\nallo\naddb\n' | 113 test_string = 'ahah\naccb\nallo\naddb\n' |
112 self._inner(args, test_string) | 114 self._inner(args, test_string) |
113 self.checkstdout('\n________ running \'boo foo bar\' in \'bleh\'\n' | 115 self.checkstdout('\n________ running \'boo foo bar\' in \'bleh\'\n' |
114 'ahah\naccb\nallo\naddb\n\n' | 116 'ahah\naccb\nallo\naddb\n\n' |
115 '________ running \'boo foo bar\' in \'bleh\'\nahah\naccb\nallo\naddb\n'
) | 117 '________ running \'boo foo bar\' in \'bleh\'\nahah\naccb\nallo\naddb' |
| 118 '\n') |
116 | 119 |
117 def testNoLF(self): | 120 def testNoLF(self): |
118 # Exactly as testCheckCallAndFilterAndHeader without trailing \n | 121 # Exactly as testCheckCallAndFilterAndHeader without trailing \n |
119 args = ['boo', 'foo', 'bar'] | 122 args = ['boo', 'foo', 'bar'] |
120 test_string = 'ahah\naccb\nallo\naddb' | 123 test_string = 'ahah\naccb\nallo\naddb' |
121 self._inner(args, test_string) | 124 self._inner(args, test_string) |
122 self.checkstdout('\n________ running \'boo foo bar\' in \'bleh\'\n' | 125 self.checkstdout('\n________ running \'boo foo bar\' in \'bleh\'\n' |
123 'ahah\naccb\nallo\naddb\n' | 126 'ahah\naccb\nallo\naddb\n' |
124 '________ running \'boo foo bar\' in \'bleh\'\nahah\naccb\nallo\naddb') | 127 '________ running \'boo foo bar\' in \'bleh\'\nahah\naccb\nallo\naddb') |
125 | 128 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 out_url, out_rev = gclient_utils.SplitUrlRevision("%s@%s" % (url, rev)) | 179 out_url, out_rev = gclient_utils.SplitUrlRevision("%s@%s" % (url, rev)) |
177 self.assertEquals(out_rev, rev) | 180 self.assertEquals(out_rev, rev) |
178 self.assertEquals(out_url, url) | 181 self.assertEquals(out_url, url) |
179 | 182 |
180 | 183 |
181 if __name__ == '__main__': | 184 if __name__ == '__main__': |
182 import unittest | 185 import unittest |
183 unittest.main() | 186 unittest.main() |
184 | 187 |
185 # vim: ts=2:sw=2:tw=80:et: | 188 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |