| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 os | 6 import os |
| 7 import StringIO | 7 import StringIO |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | 10 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 11 | 11 |
| 12 from testing_support.super_mox import SuperMoxTestBase | 12 from testing_support.super_mox import SuperMoxTestBase |
| 13 from testing_support import trial_dir | 13 from testing_support import trial_dir |
| 14 | 14 |
| 15 import gclient_utils | 15 import gclient_utils |
| 16 import subprocess2 | 16 import subprocess2 |
| 17 | 17 |
| 18 | 18 |
| 19 class GclientUtilBase(SuperMoxTestBase): | 19 class GclientUtilBase(SuperMoxTestBase): |
| 20 def setUp(self): | 20 def setUp(self): |
| 21 super(GclientUtilBase, self).setUp() | 21 super(GclientUtilBase, self).setUp() |
| 22 gclient_utils.sys.stdout.flush = lambda: None | 22 gclient_utils.sys.stdout.flush = lambda: None |
| 23 self.mox.StubOutWithMock(subprocess2, 'Popen') | 23 self.mox.StubOutWithMock(subprocess2, 'Popen') |
| 24 self.mox.StubOutWithMock(subprocess2, 'communicate') | 24 self.mox.StubOutWithMock(subprocess2, 'communicate') |
| 25 | 25 |
| 26 | 26 |
| 27 class GclientUtilsUnittest(GclientUtilBase): | |
| 28 """General gclient_utils.py tests.""" | |
| 29 def testMembersChanged(self): | |
| 30 members = [ | |
| 31 'Annotated', 'AutoFlush', 'CheckCallAndFilter', 'CommandToStr', | |
| 32 'CheckCallAndFilterAndHeader', 'Error', 'ExecutionQueue', 'FileRead', | |
| 33 'FileWrite', 'FindFileUpwards', 'FindGclientRoot', | |
| 34 'GetGClientRootAndEntries', 'GetEditor', 'GetExeSuffix', | |
| 35 'GetMacWinOrLinux', 'GitFilter', 'IsDateRevision', 'MakeDateRevision', | |
| 36 'MakeFileAutoFlush', 'MakeFileAnnotated', 'PathDifference', | |
| 37 'ParseCodereviewSettingsContent', 'NumLocalCpus', 'PrintableObject', | |
| 38 'RETRY_INITIAL_SLEEP', 'RETRY_MAX', 'RunEditor', 'GCLIENT_CHILDREN', | |
| 39 'GCLIENT_CHILDREN_LOCK', 'GClientChildren', 'SplitUrlRevision', | |
| 40 'SyntaxErrorToError', 'UpgradeToHttps', 'Wrapper', 'WorkItem', | |
| 41 'codecs', 'lockedmethod', 'logging', 'os', 'pipes', 'Queue', 're', | |
| 42 'rmtree', 'safe_makedirs', 'safe_rename', 'stat', 'subprocess', | |
| 43 'subprocess2', 'sys', 'tempfile', 'threading', 'time', 'urlparse', | |
| 44 | |
| 45 ] | |
| 46 # If this test fails, you should add the relevant test. | |
| 47 self.compareMembers(gclient_utils, members) | |
| 48 | |
| 49 | |
| 50 | |
| 51 class CheckCallAndFilterTestCase(GclientUtilBase): | 27 class CheckCallAndFilterTestCase(GclientUtilBase): |
| 52 class ProcessIdMock(object): | 28 class ProcessIdMock(object): |
| 53 def __init__(self, test_string): | 29 def __init__(self, test_string): |
| 54 self.stdout = StringIO.StringIO(test_string) | 30 self.stdout = StringIO.StringIO(test_string) |
| 55 self.pid = 9284 | 31 self.pid = 9284 |
| 56 # pylint: disable=R0201 | 32 # pylint: disable=R0201 |
| 57 def wait(self): | 33 def wait(self): |
| 58 return 0 | 34 return 0 |
| 59 | 35 |
| 60 def _inner(self, args, test_string): | 36 def _inner(self, args, test_string): |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 for content, expected in values: | 192 for content, expected in values: |
| 217 self.assertEquals( | 193 self.assertEquals( |
| 218 expected, gclient_utils.ParseCodereviewSettingsContent(content)) | 194 expected, gclient_utils.ParseCodereviewSettingsContent(content)) |
| 219 | 195 |
| 220 | 196 |
| 221 if __name__ == '__main__': | 197 if __name__ == '__main__': |
| 222 import unittest | 198 import unittest |
| 223 unittest.main() | 199 unittest.main() |
| 224 | 200 |
| 225 # vim: ts=2:sw=2:tw=80:et: | 201 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |