| 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 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" | 6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" |
| 7 | 7 |
| 8 import exceptions | 8 import exceptions |
| 9 import os | 9 import os |
| 10 import StringIO | 10 import StringIO |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 self.mox.StubOutWithMock(presubmit, 'os') | 46 self.mox.StubOutWithMock(presubmit, 'os') |
| 47 self.mox.StubOutWithMock(presubmit.os, 'path') | 47 self.mox.StubOutWithMock(presubmit.os, 'path') |
| 48 presubmit.os.sep = os_sep | 48 presubmit.os.sep = os_sep |
| 49 presubmit.os.path.join = os_path_join | 49 presubmit.os.path.join = os_path_join |
| 50 presubmit.os.path.dirname = os_path_dirname | 50 presubmit.os.path.dirname = os_path_dirname |
| 51 presubmit.os.path.normpath = os_path_normpath | 51 presubmit.os.path.normpath = os_path_normpath |
| 52 presubmit.os.path.splitext = os_path_splitext | 52 presubmit.os.path.splitext = os_path_splitext |
| 53 self.mox.StubOutWithMock(presubmit, 'random') | 53 self.mox.StubOutWithMock(presubmit, 'random') |
| 54 self.mox.StubOutWithMock(presubmit, 'sys') | 54 self.mox.StubOutWithMock(presubmit, 'sys') |
| 55 presubmit._ASKED_FOR_FEEDBACK = False | 55 presubmit._ASKED_FOR_FEEDBACK = False |
| 56 presubmit.os.path.commonprefix = os_path_commonprefix |
| 57 self.fake_root_dir = self.RootDir() |
| 56 # Special mocks. | 58 # Special mocks. |
| 57 def MockAbsPath(f): | 59 def MockAbsPath(f): |
| 58 return f | 60 return f |
| 61 def MockChdir(f): |
| 62 return None |
| 59 presubmit.os.path.abspath = MockAbsPath | 63 presubmit.os.path.abspath = MockAbsPath |
| 60 presubmit.os.path.commonprefix = os_path_commonprefix | 64 presubmit.os.getcwd = self.RootDir |
| 61 self.fake_root_dir = self.RootDir() | 65 presubmit.os.chdir = MockChdir |
| 62 self.mox.StubOutWithMock(presubmit.gclient_scm, 'CaptureSVNInfo') | 66 self.mox.StubOutWithMock(presubmit.gclient_scm, 'CaptureSVNInfo') |
| 63 self.mox.StubOutWithMock(presubmit.gcl, 'GetSVNFileProperty') | 67 self.mox.StubOutWithMock(presubmit.gcl, 'GetSVNFileProperty') |
| 64 self.mox.StubOutWithMock(presubmit.gcl, 'ReadFile') | 68 self.mox.StubOutWithMock(presubmit.gcl, 'ReadFile') |
| 65 | 69 |
| 66 | 70 |
| 67 class PresubmitUnittest(PresubmitTestsBase): | 71 class PresubmitUnittest(PresubmitTestsBase): |
| 68 """General presubmit_support.py tests (excluding InputApi and OutputApi).""" | 72 """General presubmit_support.py tests (excluding InputApi and OutputApi).""" |
| 69 def testMembersChanged(self): | 73 def testMembersChanged(self): |
| 70 self.mox.ReplayAll() | 74 self.mox.ReplayAll() |
| 71 members = [ | 75 members = [ |
| (...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 process.communicate().AndReturn(('', '')) | 1412 process.communicate().AndReturn(('', '')) |
| 1409 self.mox.ReplayAll() | 1413 self.mox.ReplayAll() |
| 1410 | 1414 |
| 1411 results = presubmit_canned_checks.RunPythonUnitTests( | 1415 results = presubmit_canned_checks.RunPythonUnitTests( |
| 1412 input_api, presubmit.OutputApi, ['test_module']) | 1416 input_api, presubmit.OutputApi, ['test_module']) |
| 1413 self.assertEquals(len(results), 0) | 1417 self.assertEquals(len(results), 0) |
| 1414 | 1418 |
| 1415 | 1419 |
| 1416 if __name__ == '__main__': | 1420 if __name__ == '__main__': |
| 1417 unittest.main() | 1421 unittest.main() |
| OLD | NEW |