Modified: trunk/Tools/ChangeLog (266639 => 266640)
--- trunk/Tools/ChangeLog 2020-09-04 21:58:36 UTC (rev 266639)
+++ trunk/Tools/ChangeLog 2020-09-04 22:29:23 UTC (rev 266640)
@@ -1,5 +1,18 @@
2020-09-04 Jonathan Bedard <[email protected]>
+ [webkitcorepy] Add mock Response object
+ https://bugs.webkit.org/show_bug.cgi?id=216150
+ <rdar://problem/68307522>
+
+ Reviewed by Dewei Zhu.
+
+ * Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py: Bump version.
+ * Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py:
+ * Scripts/libraries/webkitcorepy/webkitcorepy/mocks/requests.py: Added.
+ (Response): A response object similar to the one used by requests.
+
+2020-09-04 Jonathan Bedard <[email protected]>
+
run-webkit-tests rebuilds ImageDiff every time
https://bugs.webkit.org/show_bug.cgi?id=204420
<rdar://problem/68232690>
Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py (266639 => 266640)
--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py 2020-09-04 21:58:36 UTC (rev 266639)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py 2020-09-04 22:29:23 UTC (rev 266640)
@@ -35,7 +35,7 @@
from webkitcorepy.subprocess_utils import TimeoutExpired, CompletedProcess, run
from webkitcorepy.output_capture import LoggerCapture, OutputCapture, OutputDuplicate
-version = Version(0, 4, 5)
+version = Version(0, 4, 6)
from webkitcorepy.autoinstall import Package, AutoInstall
if sys.version_info > (3, 0):
Modified: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py (266639 => 266640)
--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py 2020-09-04 21:58:36 UTC (rev 266639)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py 2020-09-04 22:29:23 UTC (rev 266640)
@@ -23,3 +23,5 @@
from webkitcorepy.mocks.context_stack import ContextStack
from webkitcorepy.mocks.time_ import Time
from webkitcorepy.mocks.subprocess import ProcessCompletion, Subprocess
+
+from webkitcorepy.mocks.requests import Response
Copied: trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/requests.py (from rev 266638, trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/__init__.py) (0 => 266640)
--- trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/requests.py (rev 0)
+++ trunk/Tools/Scripts/libraries/webkitcorepy/webkitcorepy/mocks/requests.py 2020-09-04 22:29:23 UTC (rev 266640)
@@ -0,0 +1,62 @@
+# Copyright (C) 2020 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (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 json
+
+
+class Response(object):
+ @staticmethod
+ def fromText(data, url=""
+ assert isinstance(data, str)
+ return Response(text=data, url=""
+
+ @staticmethod
+ def fromJson(data, url=""
+ assert isinstance(data, list) or isinstance(data, dict)
+ return Response(text=json.dumps(data), url=""
+
+ @staticmethod
+ def create404(url=""
+ return Response(status_code=404, url=""
+
+ def __init__(self, status_code=None, text=None, url=""
+ if status_code is not None:
+ self.status_code = status_code
+ elif text is not None:
+ self.status_code = 200
+ else:
+ self.status_code = 204 # No content
+ self.text = text
+ self.url = ""
+
+ def json(self):
+ return json.loads(self.text)
+
+ def iter_content(self, chunk_size=4096):
+ for i in range(0, len(self.text), chunk_size):
+ yield self.text[i:i + chunk_size]
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, *args, **kwargs):
+ pass