OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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.py. | 6 """Unit tests for gclient.py. |
7 | 7 |
8 See gclient_smoketest.py for integration tests. | 8 See gclient_smoketest.py for integration tests. |
9 """ | 9 """ |
10 | 10 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 while True: | 192 while True: |
193 items.append(self.processed.get_nowait()) | 193 items.append(self.processed.get_nowait()) |
194 except Queue.Empty: | 194 except Queue.Empty: |
195 pass | 195 pass |
196 return items | 196 return items |
197 | 197 |
198 def testAutofix(self): | 198 def testAutofix(self): |
199 # Invalid urls causes pain when specifying requirements. Make sure it's | 199 # Invalid urls causes pain when specifying requirements. Make sure it's |
200 # auto-fixed. | 200 # auto-fixed. |
201 d = gclient.Dependency( | 201 d = gclient.Dependency( |
202 None, 'name', 'proto://host/path/@revision', None, None, | 202 None, 'name', 'proto://host/path/@revision', None, None, None, |
203 None, '', True) | 203 None, '', True) |
204 self.assertEquals('proto://host/path@revision', d.url) | 204 self.assertEquals('proto://host/path@revision', d.url) |
205 | 205 |
206 def testStr(self): | 206 def testStr(self): |
207 # Make sure __str__() works fine. | 207 # Make sure __str__() works fine. |
208 # pylint: disable=W0212 | 208 # pylint: disable=W0212 |
209 parser = gclient.Parser() | 209 parser = gclient.Parser() |
210 options, _ = parser.parse_args([]) | 210 options, _ = parser.parse_args([]) |
211 obj = gclient.GClient('foo', options) | 211 obj = gclient.GClient('foo', options) |
212 obj.dependencies.append( | 212 obj.dependencies.append( |
213 gclient.Dependency(obj, 'foo', 'url', None, None, None, 'DEPS', True)) | 213 gclient.Dependency(obj, 'foo', 'url', None, None, None, None, 'DEPS', |
| 214 True)) |
214 obj.dependencies.append( | 215 obj.dependencies.append( |
215 gclient.Dependency(obj, 'bar', 'url', None, None, None, 'DEPS', True)) | 216 gclient.Dependency(obj, 'bar', 'url', None, None, None, None, 'DEPS', |
| 217 True)) |
216 obj.dependencies[0].dependencies.append( | 218 obj.dependencies[0].dependencies.append( |
217 gclient.Dependency( | 219 gclient.Dependency( |
218 obj.dependencies[0], 'foo/dir1', 'url', None, None, None, 'DEPS', | 220 obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None, |
219 True)) | 221 'DEPS', True)) |
220 obj.dependencies[0].dependencies.append( | 222 obj.dependencies[0].dependencies.append( |
221 gclient.Dependency( | 223 gclient.Dependency( |
222 obj.dependencies[0], 'foo/dir2', | 224 obj.dependencies[0], 'foo/dir2', |
223 gclient.GClientKeywords.FromImpl('bar'), None, None, None, 'DEPS', | 225 gclient.GClientKeywords.FromImpl('bar'), None, None, None, None, |
224 True)) | 226 'DEPS', True)) |
225 obj.dependencies[0].dependencies.append( | 227 obj.dependencies[0].dependencies.append( |
226 gclient.Dependency( | 228 gclient.Dependency( |
227 obj.dependencies[0], 'foo/dir3', | 229 obj.dependencies[0], 'foo/dir3', |
228 gclient.GClientKeywords.FileImpl('url'), None, None, None, 'DEPS', | 230 gclient.GClientKeywords.FileImpl('url'), None, None, None, None, |
229 True)) | 231 'DEPS', True)) |
230 obj.dependencies[0]._file_list.append('foo') | 232 obj.dependencies[0]._file_list.append('foo') |
231 self.assertEquals(434, len(str(obj)), '%d\n%s' % (len(str(obj)), str(obj))) | 233 self.assertEquals(434, len(str(obj)), '%d\n%s' % (len(str(obj)), str(obj))) |
232 | 234 |
233 | 235 |
234 if __name__ == '__main__': | 236 if __name__ == '__main__': |
235 logging.basicConfig( | 237 logging.basicConfig( |
236 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 238 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
237 min(sys.argv.count('-v'), 3)], | 239 min(sys.argv.count('-v'), 3)], |
238 format='%(asctime).19s %(levelname)s %(filename)s:' | 240 format='%(asctime).19s %(levelname)s %(filename)s:' |
239 '%(lineno)s %(message)s') | 241 '%(lineno)s %(message)s') |
240 unittest.main() | 242 unittest.main() |
OLD | NEW |