| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 self.mock(git_cl.rietveld, 'Rietveld', RietveldMock) | 94 self.mock(git_cl.rietveld, 'Rietveld', RietveldMock) |
| 95 self.mock(git_cl.rietveld, 'CachingRietveld', RietveldMock) | 95 self.mock(git_cl.rietveld, 'CachingRietveld', RietveldMock) |
| 96 self.mock(git_cl.upload, 'RealMain', self.fail) | 96 self.mock(git_cl.upload, 'RealMain', self.fail) |
| 97 self.mock(git_cl.watchlists, 'Watchlists', WatchlistsMock) | 97 self.mock(git_cl.watchlists, 'Watchlists', WatchlistsMock) |
| 98 self.mock(git_cl.auth, 'get_authenticator_for_host', AuthenticatorMock) | 98 self.mock(git_cl.auth, 'get_authenticator_for_host', AuthenticatorMock) |
| 99 self.mock(git_cl.auth, '_should_use_oauth2', lambda: False) | 99 self.mock(git_cl.auth, '_should_use_oauth2', lambda: False) |
| 100 # It's important to reset settings to not have inter-tests interference. | 100 # It's important to reset settings to not have inter-tests interference. |
| 101 git_cl.settings = None | 101 git_cl.settings = None |
| 102 | 102 |
| 103 def tearDown(self): | 103 def tearDown(self): |
| 104 if not self.has_failed(): | 104 try: |
| 105 self.assertEquals([], self.calls) | 105 if not self.has_failed(): |
| 106 super(TestGitCl, self).tearDown() | 106 self.assertEquals([], self.calls) |
| 107 finally: |
| 108 super(TestGitCl, self).tearDown() |
| 107 | 109 |
| 108 def _mocked_call(self, *args, **_kwargs): | 110 def _mocked_call(self, *args, **_kwargs): |
| 109 self.assertTrue( | 111 self.assertTrue( |
| 110 self.calls, | 112 self.calls, |
| 111 '@%d Expected: <Missing> Actual: %r' % (self._calls_done, args)) | 113 '@%d Expected: <Missing> Actual: %r' % (self._calls_done, args)) |
| 112 expected_args, result = self.calls.pop(0) | 114 expected_args, result = self.calls.pop(0) |
| 113 # Also logs otherwise it could get caught in a try/finally and be hard to | 115 # Also logs otherwise it could get caught in a try/finally and be hard to |
| 114 # diagnose. | 116 # diagnose. |
| 115 if expected_args != args: | 117 if expected_args != args: |
| 116 msg = '@%d Expected: %r Actual: %r' % ( | 118 msg = '@%d Expected: %r Actual: %r' % ( |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 # Check target refs for pending prefix. | 853 # Check target refs for pending prefix. |
| 852 self.assertEqual('prefix/heads/master', | 854 self.assertEqual('prefix/heads/master', |
| 853 git_cl.GetTargetRef('origin', 'refs/remotes/origin/master', | 855 git_cl.GetTargetRef('origin', 'refs/remotes/origin/master', |
| 854 None, 'prefix/')) | 856 None, 'prefix/')) |
| 855 | 857 |
| 856 | 858 |
| 857 if __name__ == '__main__': | 859 if __name__ == '__main__': |
| 858 git_cl.logging.basicConfig( | 860 git_cl.logging.basicConfig( |
| 859 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 861 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
| 860 unittest.main() | 862 unittest.main() |
| OLD | NEW |