From 445c896d9f750fb9f3a0956a379531b2c7c55e3b Mon Sep 17 00:00:00 2001 From: "wychen@chromium.org" Date: Tue, 28 Apr 2015 23:30:05 +0000 Subject: [PATCH] Fix mock restoration in git_cl_test The assertion in TestGitCl.tearDown should be done after super.tearDown is finished. Otherwise if the assertion fails, mocked objects won't be restored properly, and the next TestCase would be affected. Review URL: https://codereview.chromium.org/1093943002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@295049 0039d316-1c4b-4281-b951-d872f2087c98 --- tests/git_cl_test.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index ed1d7a563..c1eebebf7 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -100,9 +100,11 @@ class TestGitCl(TestCase): git_cl.settings = None def tearDown(self): - if not self.has_failed(): - self.assertEquals([], self.calls) - super(TestGitCl, self).tearDown() + try: + if not self.has_failed(): + self.assertEquals([], self.calls) + finally: + super(TestGitCl, self).tearDown() def _mocked_call(self, *args, **_kwargs): self.assertTrue(