Python 3: Add support in webkitpy.common.net
https://bugs.webkit.org/show_bug.cgi?id=202464
Reviewed by Dewei Zhu.
* Scripts/test-webkitpy-python3: Add webkitpy.common.net.
* Scripts/webkitpy/common/net/credentials_unittest.py: Replace raw_input with input for Python3.
* Scripts/webkitpy/common/net/ewsserver.py:
* Scripts/webkitpy/common/net/resultsjsonparser.py:
(ParsedJSONResults.__init__): Sort results by test name.
* Scripts/webkitpy/common/net/resultsjsonparser_unittest.py:
(test_basic): Sort results by test name.
* Scripts/webkitpy/common/net/statusserver.py:
(StatusServer._fetch_url):
* Scripts/webkitpy/common/net/unittestresults_unittest.py:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 42393ff..23eb424 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,21 @@
+2019-10-21 Jonathan Bedard <jbedard@apple.com>
+
+ Python 3: Add support in webkitpy.common.net
+ https://bugs.webkit.org/show_bug.cgi?id=202464
+
+ Reviewed by Dewei Zhu.
+
+ * Scripts/test-webkitpy-python3: Add webkitpy.common.net.
+ * Scripts/webkitpy/common/net/credentials_unittest.py: Replace raw_input with input for Python3.
+ * Scripts/webkitpy/common/net/ewsserver.py:
+ * Scripts/webkitpy/common/net/resultsjsonparser.py:
+ (ParsedJSONResults.__init__): Sort results by test name.
+ * Scripts/webkitpy/common/net/resultsjsonparser_unittest.py:
+ (test_basic): Sort results by test name.
+ * Scripts/webkitpy/common/net/statusserver.py:
+ (StatusServer._fetch_url):
+ * Scripts/webkitpy/common/net/unittestresults_unittest.py:
+
2019-10-18 Aakash Jain <aakash_jain@apple.com>
EWS should have a way to retry a patch
diff --git a/Tools/Scripts/test-webkitpy-python3 b/Tools/Scripts/test-webkitpy-python3
index 813fa45..89666b7 100755
--- a/Tools/Scripts/test-webkitpy-python3
+++ b/Tools/Scripts/test-webkitpy-python3
@@ -34,9 +34,7 @@
PYTHON3_COMPATIBLE_DIRECTORIES = [
'webkitpy.common.system',
'webkitpy.common.thread',
- 'webkitpy.common.net.bugzilla',
- 'webkitpy.common.net.buildbot',
- 'webkitpy.common.net.irc',
+ 'webkitpy.common.net',
'webkitpy.common.watchlist',
]
diff --git a/Tools/Scripts/webkitpy/common/net/credentials_unittest.py b/Tools/Scripts/webkitpy/common/net/credentials_unittest.py
index 82440c5..c3737fc 100644
--- a/Tools/Scripts/webkitpy/common/net/credentials_unittest.py
+++ b/Tools/Scripts/webkitpy/common/net/credentials_unittest.py
@@ -1,4 +1,5 @@
# Copyright (C) 2009 Google Inc. All rights reserved.
+# Copyright (C) 2019 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
@@ -27,6 +28,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
+import sys
import tempfile
import unittest
@@ -37,6 +39,11 @@
from webkitpy.tool.mocktool import MockOptions
from webkitpy.common.system.executive_mock import MockExecutive
+if sys.version_info > (3, 0):
+ input_func = input
+else:
+ input_func = raw_input
+
# FIXME: Other unit tests probably want this class.
class _TemporaryDirectory(object):
@@ -193,11 +200,11 @@
class FakeUser(MockUser):
@classmethod
- def prompt(cls, message, repeat=1, raw_input=raw_input):
+ def prompt(cls, message, repeat=1, raw_input=input_func):
return "test@webkit.org"
@classmethod
- def prompt_password(cls, message, repeat=1, raw_input=raw_input):
+ def prompt_password(cls, message, repeat=1, raw_input=input_func):
raise AssertionError("should not prompt for password")
with _TemporaryDirectory(suffix="not_a_git_repo") as temp_dir_path:
@@ -223,11 +230,11 @@
class FakeUser(MockUser):
@classmethod
- def prompt(cls, message, repeat=1, raw_input=raw_input):
+ def prompt(cls, message, repeat=1, raw_input=input_func):
return "test@webkit.org"
@classmethod
- def prompt_password(cls, message, repeat=1, raw_input=raw_input):
+ def prompt_password(cls, message, repeat=1, raw_input=input_func):
return "NOMNOMNOM"
with _TemporaryDirectory(suffix="not_a_git_repo") as temp_dir_path:
diff --git a/Tools/Scripts/webkitpy/common/net/ewsserver.py b/Tools/Scripts/webkitpy/common/net/ewsserver.py
index b19c6d4..835e80a 100644
--- a/Tools/Scripts/webkitpy/common/net/ewsserver.py
+++ b/Tools/Scripts/webkitpy/common/net/ewsserver.py
@@ -22,6 +22,7 @@
from webkitpy.common.config.urls import ewsserver_default_host
from webkitpy.common.net.networktransaction import NetworkTransaction
+from webkitpy.common.unicode_compatibility import unicode
import logging
diff --git a/Tools/Scripts/webkitpy/common/net/resultsjsonparser.py b/Tools/Scripts/webkitpy/common/net/resultsjsonparser.py
index 3980357..f7da018 100644
--- a/Tools/Scripts/webkitpy/common/net/resultsjsonparser.py
+++ b/Tools/Scripts/webkitpy/common/net/resultsjsonparser.py
@@ -1,4 +1,5 @@
# Copyright (c) 2010, Google Inc. All rights reserved.
+# Copyright (C) 2019 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
@@ -162,6 +163,7 @@
unexpected_failures.append(test_result)
self._test_results = unexpected_failures
+ self._test_results.sort(key=lambda result: result.test_name)
self._did_exceed_test_failure_limit = json_dict["interrupted"]
def did_exceed_test_failure_limit(self):
diff --git a/Tools/Scripts/webkitpy/common/net/resultsjsonparser_unittest.py b/Tools/Scripts/webkitpy/common/net/resultsjsonparser_unittest.py
index 5c767d4..141a163 100644
--- a/Tools/Scripts/webkitpy/common/net/resultsjsonparser_unittest.py
+++ b/Tools/Scripts/webkitpy/common/net/resultsjsonparser_unittest.py
@@ -1,4 +1,5 @@
# Copyright (c) 2010, Google Inc. All rights reserved.
+# Copyright (C) 2019 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
@@ -143,11 +144,13 @@
});"""
def test_basic(self):
+ self.maxDiff = None
expected_results = [
test_results.TestResult("svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr.html", [test_failures.FailureImageHashMismatch()], 0),
test_results.TestResult("fast/dom/prototype-inheritance.html", [test_failures.FailureTextMismatch(), test_failures.FailureImageHashMismatch(), test_failures.FailureAudioMismatch()], 0),
test_results.TestResult("fast/dom/prototype-strawberry.html", [test_failures.FailureDocumentLeak(['file:///Volumes/Data/slave/webkit/build/LayoutTests/fast/dom/prototype-strawberry.html'])], 0),
]
+ expected_results.sort(key=lambda result: result.test_name)
parsed_results = ParsedJSONResults(self._example_full_results_json)
self.assertEqual(expected_results, parsed_results.test_results())
self.assertTrue(parsed_results.did_exceed_test_failure_limit())
diff --git a/Tools/Scripts/webkitpy/common/net/statusserver.py b/Tools/Scripts/webkitpy/common/net/statusserver.py
index c673c8c..2c8aefe 100644
--- a/Tools/Scripts/webkitpy/common/net/statusserver.py
+++ b/Tools/Scripts/webkitpy/common/net/statusserver.py
@@ -29,14 +29,20 @@
#
# This the client designed to talk to Tools/QueueStatusServer.
+import logging
+import sys
+
from webkitpy.common.config.urls import statusserver_default_host
from webkitpy.common.net.bugzilla.attachment import Attachment
from webkitpy.common.net.networktransaction import NetworkTransaction
+from webkitpy.common.unicode_compatibility import StringIO
from webkitpy.thirdparty.BeautifulSoup import BeautifulSoup
-import StringIO
-import logging
-import urllib2
+if sys.version_info > (3, 0):
+ from urllib.error import HTTPError
+ from urllib.request import Request, urlopen
+else:
+ from urllib2 import HTTPError, Request, urlopen
_log = logging.getLogger(__name__)
@@ -221,11 +227,11 @@
def _fetch_url(self, url):
# FIXME: This should use NetworkTransaction's 404 handling instead.
try:
- request = urllib2.Request(url)
+ request = Request(url)
if self._api_key:
request.add_header(*self._authorization_header_name_and_value_pair())
- return urllib2.urlopen(request, timeout=300).read()
- except urllib2.HTTPError as e:
+ return urlopen(request, timeout=300).read()
+ except HTTPError as e:
if e.code == 404:
return None
raise e
diff --git a/Tools/Scripts/webkitpy/common/net/unittestresults_unittest.py b/Tools/Scripts/webkitpy/common/net/unittestresults_unittest.py
index 74be1ce..e798552 100644
--- a/Tools/Scripts/webkitpy/common/net/unittestresults_unittest.py
+++ b/Tools/Scripts/webkitpy/common/net/unittestresults_unittest.py
@@ -1,4 +1,5 @@
# Copyright (c) 2012, Google Inc. All rights reserved.
+# Copyright (C) 2019 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
@@ -28,7 +29,7 @@
import unittest
-from unittestresults import UnitTestResults
+from webkitpy.common.net.unittestresults import UnitTestResults
class UnitTestResultsTest(unittest.TestCase):