OLD | NEW |
1 #!/usr/bin/python | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
3 # 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 |
4 # found in the LICENSE file. | 3 # found in the LICENSE file. |
5 | 4 |
6 """Simplify unit tests based on pymox.""" | 5 """Simplify unit tests based on pymox.""" |
7 | 6 |
8 import os | 7 import os |
9 import random | 8 import random |
10 import shutil | 9 import shutil |
11 import string | 10 import string |
12 import StringIO | 11 import StringIO |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 self.mox.StubOutWithMock(parent, item) | 143 self.mox.StubOutWithMock(parent, item) |
145 except TypeError: | 144 except TypeError: |
146 raise TypeError('Couldn\'t mock %s in %s' % (item, parent.__name__)) | 145 raise TypeError('Couldn\'t mock %s in %s' % (item, parent.__name__)) |
147 | 146 |
148 def UnMock(self, obj, name): | 147 def UnMock(self, obj, name): |
149 """Restore an object inside a test.""" | 148 """Restore an object inside a test.""" |
150 for (parent, old_child, child_name) in self.mox.stubs.cache: | 149 for (parent, old_child, child_name) in self.mox.stubs.cache: |
151 if parent == obj and child_name == name: | 150 if parent == obj and child_name == name: |
152 setattr(parent, child_name, old_child) | 151 setattr(parent, child_name, old_child) |
153 break | 152 break |
OLD | NEW |