OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Provides stubs for os, sys and subprocess for testing | 4 """Provides stubs for os, sys and subprocess for testing |
5 | 5 |
6 This test allows one to test code that itself uses os, sys, and subprocess. | 6 This test allows one to test code that itself uses os, sys, and subprocess. |
7 """ | 7 """ |
8 | 8 |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 self.AdbCommands = AdbCommandsStubConstructor | 69 self.AdbCommands = AdbCommandsStubConstructor |
70 | 70 |
71 @staticmethod | 71 @staticmethod |
72 def IsAndroidSupported(): | 72 def IsAndroidSupported(): |
73 return True | 73 return True |
74 | 74 |
75 def GetAttachedDevices(self): | 75 def GetAttachedDevices(self): |
76 return self.attached_devices | 76 return self.attached_devices |
77 | 77 |
78 @staticmethod | 78 @staticmethod |
79 def HasForwarder(_): | 79 def HasForwarder(_=None): |
80 return True | 80 return True |
81 | 81 |
82 class OsModuleStub(object): | 82 class OsModuleStub(object): |
83 class OsPathModuleStub(object): | 83 class OsPathModuleStub(object): |
84 def __init__(self, sys_module): | 84 def __init__(self, sys_module): |
85 self.sys = sys_module | 85 self.sys = sys_module |
86 self.files = [] | 86 self.files = [] |
87 | 87 |
88 def exists(self, path): | 88 def exists(self, path): |
89 return path in self.files | 89 return path in self.files |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 def __init__(self): | 145 def __init__(self): |
146 self.Popen = SubprocessModuleStub.PopenStub() | 146 self.Popen = SubprocessModuleStub.PopenStub() |
147 self.PIPE = None | 147 self.PIPE = None |
148 | 148 |
149 def call(self, *args, **kwargs): | 149 def call(self, *args, **kwargs): |
150 raise NotImplementedError() | 150 raise NotImplementedError() |
151 | 151 |
152 class SysModuleStub(object): | 152 class SysModuleStub(object): |
153 def __init__(self): | 153 def __init__(self): |
154 self.platform = '' | 154 self.platform = '' |
OLD | NEW |