| 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 """Unit tests for git_cl.py.""" | 6 """Unit tests for git_cl.py.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import StringIO | 9 import StringIO |
| 10 import stat | 10 import stat |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 self.calls = [] | 79 self.calls = [] |
| 80 self._calls_done = 0 | 80 self._calls_done = 0 |
| 81 self.mock(subprocess2, 'call', self._mocked_call) | 81 self.mock(subprocess2, 'call', self._mocked_call) |
| 82 self.mock(subprocess2, 'check_call', self._mocked_call) | 82 self.mock(subprocess2, 'check_call', self._mocked_call) |
| 83 self.mock(subprocess2, 'check_output', self._mocked_call) | 83 self.mock(subprocess2, 'check_output', self._mocked_call) |
| 84 self.mock(subprocess2, 'communicate', self._mocked_call) | 84 self.mock(subprocess2, 'communicate', self._mocked_call) |
| 85 self.mock(git_common, 'is_dirty_git_tree', lambda x: False) | 85 self.mock(git_common, 'is_dirty_git_tree', lambda x: False) |
| 86 self.mock(git_common, 'get_or_create_merge_base', | 86 self.mock(git_common, 'get_or_create_merge_base', |
| 87 lambda *a: ( | 87 lambda *a: ( |
| 88 self._mocked_call(['get_or_create_merge_base']+list(a)))) | 88 self._mocked_call(['get_or_create_merge_base']+list(a)))) |
| 89 self.mock(git_cl, 'BranchExists', lambda _: True) |
| 89 self.mock(git_cl, 'FindCodereviewSettingsFile', lambda: '') | 90 self.mock(git_cl, 'FindCodereviewSettingsFile', lambda: '') |
| 90 self.mock(git_cl, 'ask_for_data', self._mocked_call) | 91 self.mock(git_cl, 'ask_for_data', self._mocked_call) |
| 91 self.mock(git_cl.breakpad, 'post', self._mocked_call) | 92 self.mock(git_cl.breakpad, 'post', self._mocked_call) |
| 92 self.mock(git_cl.breakpad, 'SendStack', self._mocked_call) | 93 self.mock(git_cl.breakpad, 'SendStack', self._mocked_call) |
| 93 self.mock(git_cl.presubmit_support, 'DoPresubmitChecks', PresubmitMock) | 94 self.mock(git_cl.presubmit_support, 'DoPresubmitChecks', PresubmitMock) |
| 94 self.mock(git_cl.rietveld, 'Rietveld', RietveldMock) | 95 self.mock(git_cl.rietveld, 'Rietveld', RietveldMock) |
| 95 self.mock(git_cl.rietveld, 'CachingRietveld', RietveldMock) | 96 self.mock(git_cl.rietveld, 'CachingRietveld', RietveldMock) |
| 96 self.mock(git_cl.upload, 'RealMain', self.fail) | 97 self.mock(git_cl.upload, 'RealMain', self.fail) |
| 97 self.mock(git_cl.watchlists, 'Watchlists', WatchlistsMock) | 98 self.mock(git_cl.watchlists, 'Watchlists', WatchlistsMock) |
| 98 self.mock(git_cl.auth, 'get_authenticator_for_host', AuthenticatorMock) | 99 self.mock(git_cl.auth, 'get_authenticator_for_host', AuthenticatorMock) |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 self.calls += [ | 907 self.calls += [ |
| 907 ((['git', 'apply', '--index', '-p0', '--3way'],), '', | 908 ((['git', 'apply', '--index', '-p0', '--3way'],), '', |
| 908 subprocess2.CalledProcessError(1, '', '', '', '')), | 909 subprocess2.CalledProcessError(1, '', '', '', '')), |
| 909 ] | 910 ] |
| 910 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) | 911 self.assertNotEqual(git_cl.main(['patch', '123456']), 0) |
| 911 | 912 |
| 912 if __name__ == '__main__': | 913 if __name__ == '__main__': |
| 913 git_cl.logging.basicConfig( | 914 git_cl.logging.basicConfig( |
| 914 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 915 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
| 915 unittest.main() | 916 unittest.main() |
| OLD | NEW |