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

Side by Side Diff: testing_support/super_mox.py

Issue 8508015: Create a new depot_tools_testing_lib to move utility modules there (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Renamed to testing_support Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « testing_support/patches_data.py ('k') | testing_support/trial_dir.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 """Simplify unit tests based on pymox.""" 5 """Simplify unit tests based on pymox."""
6 6
7 import os 7 import os
8 import random 8 import random
9 import shutil 9 import shutil
10 import string 10 import string
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 self.relpath = self.String(200) 83 self.relpath = self.String(200)
84 84
85 def tearDown(self): 85 def tearDown(self):
86 pass 86 pass
87 87
88 88
89 class StdoutCheck(object): 89 class StdoutCheck(object):
90 def setUp(self): 90 def setUp(self):
91 # Override the mock with a StringIO, it's much less painful to test. 91 # Override the mock with a StringIO, it's much less painful to test.
92 self._old_stdout = sys.stdout 92 self._old_stdout = sys.stdout
93 sys.stdout = StringIO.StringIO() 93 stdout = StringIO.StringIO()
94 sys.stdout.flush = lambda: None 94 stdout.flush = lambda: None
95 sys.stdout = stdout
95 96
96 def tearDown(self): 97 def tearDown(self):
97 try: 98 try:
98 # If sys.stdout was used, self.checkstdout() must be called. 99 # If sys.stdout was used, self.checkstdout() must be called.
99 # pylint: disable=E1101 100 # pylint: disable=E1101
100 self.assertEquals('', sys.stdout.getvalue()) 101 self.assertEquals('', sys.stdout.getvalue())
101 except AttributeError: 102 except AttributeError:
102 pass 103 pass
103 sys.stdout = self._old_stdout 104 sys.stdout = self._old_stdout
104 105
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 except TypeError, e: 145 except TypeError, e:
145 raise TypeError( 146 raise TypeError(
146 'Couldn\'t mock %s in %s: %s' % (item, parent.__name__, e)) 147 'Couldn\'t mock %s in %s: %s' % (item, parent.__name__, e))
147 148
148 def UnMock(self, obj, name): 149 def UnMock(self, obj, name):
149 """Restore an object inside a test.""" 150 """Restore an object inside a test."""
150 for (parent, old_child, child_name) in self.mox.stubs.cache: 151 for (parent, old_child, child_name) in self.mox.stubs.cache:
151 if parent == obj and child_name == name: 152 if parent == obj and child_name == name:
152 setattr(parent, child_name, old_child) 153 setattr(parent, child_name, old_child)
153 break 154 break
OLDNEW
« no previous file with comments | « testing_support/patches_data.py ('k') | testing_support/trial_dir.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698