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

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/mock_tool.py

Issue 2135603003: Make MockOptions a thin wrapper around optparse.Values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 5 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: third_party/WebKit/Tools/Scripts/webkitpy/tool/mock_tool.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/tool/mock_tool.py b/third_party/WebKit/Tools/Scripts/webkitpy/tool/mock_tool.py
index 0a84a7d5e6fa2f14df1e401d2146f18d5ca67cba..97aac7f5643da89d4a91c9f3b922a099acf2d6f7 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/tool/mock_tool.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/tool/mock_tool.py
@@ -26,29 +26,17 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import optparse
+
from webkitpy.common.host_mock import MockHost
-# FIXME: We should just replace this with optparse.Values(default=kwargs)
-class MockOptions(object):
- """Mock implementation of optparse.Values."""
+# TODO(qyearsley): Replace uses of this with using optparse.Values directly (crbug.com/626679).
+class MockOptions(optparse.Values):
def __init__(self, **kwargs):
- # The caller can set option values using keyword arguments. We don't
- # set any values by default because we don't know how this
- # object will be used. Generally speaking unit tests should
- # subclass this or provider wrapper functions that set a common
- # set of options.
- self.update(**kwargs)
-
- def update(self, **kwargs):
- self.__dict__.update(**kwargs)
- return self
-
- def ensure_value(self, key, value):
- if getattr(self, key, None) is None:
- self.__dict__[key] = value
- return self.__dict__[key]
+ # Not using super because optparse.Values is an old-style class.
+ optparse.Values.__init__(self, defaults=kwargs)
class MockWebKitPatch(MockHost):

Powered by Google App Engine
This is Rietveld 408576698