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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, |
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): |
| 207 # Make sure __str__() works fine. |
| 208 # pylint: disable=W0212 |
| 209 parser = gclient.Parser() |
| 210 options, _ = parser.parse_args([]) |
| 211 obj = gclient.GClient('foo', options) |
| 212 obj.dependencies.append( |
| 213 gclient.Dependency(obj, 'foo', 'url', None, None, None, 'DEPS', True)) |
| 214 obj.dependencies.append( |
| 215 gclient.Dependency(obj, 'bar', 'url', None, None, None, 'DEPS', True)) |
| 216 obj.dependencies[0].dependencies.append( |
| 217 gclient.Dependency( |
| 218 obj.dependencies[0], 'foo/dir1', 'url', None, None, None, 'DEPS', |
| 219 True)) |
| 220 obj.dependencies[0].dependencies.append( |
| 221 gclient.Dependency( |
| 222 obj.dependencies[0], 'foo/dir2', |
| 223 gclient.GClientKeywords.FromImpl('bar'), None, None, None, 'DEPS', |
| 224 True)) |
| 225 obj.dependencies[0].dependencies.append( |
| 226 gclient.Dependency( |
| 227 obj.dependencies[0], 'foo/dir3', |
| 228 gclient.GClientKeywords.FileImpl('url'), None, None, None, 'DEPS', |
| 229 True)) |
| 230 obj.dependencies[0]._file_list.append('foo') |
| 231 self.assertEquals(434, len(str(obj)), '%d\n%s' % (len(str(obj)), str(obj))) |
| 232 |
| 233 |
206 if __name__ == '__main__': | 234 if __name__ == '__main__': |
207 logging.basicConfig( | 235 logging.basicConfig( |
208 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 236 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
209 min(sys.argv.count('-v'), 3)], | 237 min(sys.argv.count('-v'), 3)], |
210 format='%(asctime).19s %(levelname)s %(filename)s:' | 238 format='%(asctime).19s %(levelname)s %(filename)s:' |
211 '%(lineno)s %(message)s') | 239 '%(lineno)s %(message)s') |
212 unittest.main() | 240 unittest.main() |
OLD | NEW |