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

Unified Diff: tools/telemetry/telemetry/unittest_util/system_stub.py

Issue 999963002: Fix system_stub.Restore(), and add a unittest to catch the bug being fixed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added Copyright info for Chromium presubmit. Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/telemetry/telemetry/unittest_util/system_stub_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/unittest_util/system_stub.py
diff --git a/tools/telemetry/telemetry/unittest_util/system_stub.py b/tools/telemetry/telemetry/unittest_util/system_stub.py
index 31f71f81d67d8218110062a3d3c54bbb78118757..634431e3c545b21823c18246f62f39601d52069f 100644
--- a/tools/telemetry/telemetry/unittest_util/system_stub.py
+++ b/tools/telemetry/telemetry/unittest_util/system_stub.py
@@ -49,7 +49,13 @@ class Override(object):
def Restore(self):
for module_name, original_module in self._overrides.iteritems():
- setattr(self._base_module, module_name, original_module)
+ if original_module is None:
+ # This will happen when we override built-in functions, like open.
+ # If we don't delete the attribute, we will shadow the built-in
+ # function with an attribute set to None.
+ delattr(self._base_module, module_name)
+ else:
+ setattr(self._base_module, module_name, original_module)
self._overrides = {}
« no previous file with comments | « no previous file | tools/telemetry/telemetry/unittest_util/system_stub_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698