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

Side by Side Diff: appengine/third_party_local/depot_tools/auto_stub.py

Issue 2117833003: endpoints -> webapp2 adapter (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: decode bool field Created 4 years, 5 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
OLDNEW
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 __version__ = '1.0' 5 __version__ = '1.0'
6 6
7 import collections 7 import collections
8 import inspect 8 import inspect
9 import unittest 9 import unittest
10 import sys
10 11
11 12
12 class AutoStubMixIn(object): 13 class AutoStubMixIn(object):
13 """Automatically restores stubbed functions on unit test teardDown. 14 """Automatically restores stubbed functions on unit test teardDown.
14 15
15 It's an extremely lightweight mocking class that doesn't require bookeeping. 16 It's an extremely lightweight mocking class that doesn't require bookeeping.
16 """ 17 """
17 _saved = None 18 _saved = None
18 19
19 def mock(self, obj, member, mock): 20 def mock(self, obj, member, mock):
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 64
64 65
65 class TestCase(unittest.TestCase, AutoStubMixIn): 66 class TestCase(unittest.TestCase, AutoStubMixIn):
66 """Adds self.mock() and self.has_failed() to a TestCase.""" 67 """Adds self.mock() and self.has_failed() to a TestCase."""
67 def tearDown(self): 68 def tearDown(self):
68 AutoStubMixIn.tearDown(self) 69 AutoStubMixIn.tearDown(self)
69 unittest.TestCase.tearDown(self) 70 unittest.TestCase.tearDown(self)
70 71
71 def has_failed(self): 72 def has_failed(self):
72 """Returns True if the test has failed.""" 73 """Returns True if the test has failed."""
73 return not self._resultForDoCleanups.wasSuccessful() 74 if self._resultForDoCleanups:
75 return not self._resultForDoCleanups.wasSuccessful()
76 ex, _, _, = sys.exc_info()
77 return bool(ex)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698