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

Unified Diff: tools/telemetry/telemetry/unittest_util/system_stub_unittest.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
Index: tools/telemetry/telemetry/unittest_util/system_stub_unittest.py
diff --git a/tools/telemetry/telemetry/unittest_util/system_stub_unittest.py b/tools/telemetry/telemetry/unittest_util/system_stub_unittest.py
index 56bf3d5238b60b70b8f13cfdc994c9438386f9f4..99ef5d40ea2b3e589705b9421287300c11ce159d 100644
--- a/tools/telemetry/telemetry/unittest_util/system_stub_unittest.py
+++ b/tools/telemetry/telemetry/unittest_util/system_stub_unittest.py
@@ -7,7 +7,7 @@ import unittest
PERF_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
from telemetry.unittest_util import system_stub
-
+from unittest_data import system_stub_test_module
class CloudStorageTest(unittest.TestCase):
SUCCESS_FILE_HASH = 'success'.zfill(40)
@@ -216,3 +216,15 @@ class CloudStorageTest(unittest.TestCase):
'/path/to/success.wpr')
# Reset state.
self.cloud_storage.SetRemotePathsForTesting()
+
+ def testOpenRestoresCorrectly(self):
+ file_path = os.path.realpath(__file__)
+ stubs = system_stub.Override(system_stub_test_module, ['open'])
+ stubs.open.files = {file_path:'contents'}
+ f = system_stub_test_module.SystemStubTest.TestOpen(file_path)
+ self.assertEqual(type(f), system_stub.OpenFunctionStub.FileStub)
+ stubs.open.files = {}
+ stubs.Restore()
+ # This will throw an error if the open stub wasn't restored correctly.
+ f = system_stub_test_module.SystemStubTest.TestOpen(file_path)
+ self.assertEqual(type(f), file)
« no previous file with comments | « tools/telemetry/telemetry/unittest_util/system_stub.py ('k') | tools/telemetry/unittest_data/system_stub_test_module.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698