Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: tests/git_cl_test.py

Issue 1093943002: Fix mock restoration in git_cl_test (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: address maruel's comment Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698