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

Side by Side Diff: testing_support/super_mox.py

Issue 14569002: Remove getpid from SuperMox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« 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 # 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 # pylint: disable=E1101 110 # pylint: disable=E1101
111 self.assertEquals(expected, value) 111 self.assertEquals(expected, value)
112 112
113 113
114 class SuperMoxTestBase(TestCaseUtils, StdoutCheck, mox.MoxTestBase): 114 class SuperMoxTestBase(TestCaseUtils, StdoutCheck, mox.MoxTestBase):
115 def setUp(self): 115 def setUp(self):
116 """Patch a few functions with know side-effects.""" 116 """Patch a few functions with know side-effects."""
117 TestCaseUtils.setUp(self) 117 TestCaseUtils.setUp(self)
118 mox.MoxTestBase.setUp(self) 118 mox.MoxTestBase.setUp(self)
119 os_to_mock = ('chdir', 'chown', 'close', 'closerange', 'dup', 'dup2', 119 os_to_mock = ('chdir', 'chown', 'close', 'closerange', 'dup', 'dup2',
120 'fchdir', 'fchmod', 'fchown', 'fdopen', 'getcwd', 'getpid', 'lseek', 120 'fchdir', 'fchmod', 'fchown', 'fdopen', 'getcwd', 'lseek',
121 'makedirs', 'mkdir', 'open', 'popen', 'popen2', 'popen3', 'popen4', 121 'makedirs', 'mkdir', 'open', 'popen', 'popen2', 'popen3', 'popen4',
122 'read', 'remove', 'removedirs', 'rename', 'renames', 'rmdir', 'symlink', 122 'read', 'remove', 'removedirs', 'rename', 'renames', 'rmdir', 'symlink',
123 'system', 'tmpfile', 'walk', 'write') 123 'system', 'tmpfile', 'walk', 'write')
124 self.MockList(os, os_to_mock) 124 self.MockList(os, os_to_mock)
125 os_path_to_mock = ('abspath', 'exists', 'getsize', 'isdir', 'isfile', 125 os_path_to_mock = ('abspath', 'exists', 'getsize', 'isdir', 'isfile',
126 'islink', 'ismount', 'lexists', 'realpath', 'samefile', 'walk') 126 'islink', 'ismount', 'lexists', 'realpath', 'samefile', 'walk')
127 self.MockList(os.path, os_path_to_mock) 127 self.MockList(os.path, os_path_to_mock)
128 self.MockList(shutil, ('rmtree')) 128 self.MockList(shutil, ('rmtree'))
129 self.MockList(subprocess, ('call', 'Popen')) 129 self.MockList(subprocess, ('call', 'Popen'))
130 # Don't mock stderr since it confuses unittests. 130 # Don't mock stderr since it confuses unittests.
(...skipping 15 matching lines...) Expand all
146 except TypeError, e: 146 except TypeError, e:
147 raise TypeError( 147 raise TypeError(
148 'Couldn\'t mock %s in %s: %s' % (item, parent.__name__, e)) 148 'Couldn\'t mock %s in %s: %s' % (item, parent.__name__, e))
149 149
150 def UnMock(self, obj, name): 150 def UnMock(self, obj, name):
151 """Restore an object inside a test.""" 151 """Restore an object inside a test."""
152 for (parent, old_child, child_name) in self.mox.stubs.cache: 152 for (parent, old_child, child_name) in self.mox.stubs.cache:
153 if parent == obj and child_name == name: 153 if parent == obj and child_name == name:
154 setattr(parent, child_name, old_child) 154 setattr(parent, child_name, old_child)
155 break 155 break
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