Python 3: Add support in webkitpy.common.net
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Oct 2019 19:34:53 +0000 (19:34 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Oct 2019 19:34:53 +0000 (19:34 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@251374 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/test-webkitpy-python3
Tools/Scripts/webkitpy/common/net/credentials_unittest.py
Tools/Scripts/webkitpy/common/net/ewsserver.py
Tools/Scripts/webkitpy/common/net/resultsjsonparser.py
Tools/Scripts/webkitpy/common/net/resultsjsonparser_unittest.py
Tools/Scripts/webkitpy/common/net/statusserver.py
Tools/Scripts/webkitpy/common/net/unittestresults_unittest.py

index 42393ff..23eb424 100644 (file)
@@ -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
index 813fa45..89666b7 100755 (executable)
@@ -34,9 +34,7 @@ import unittest
 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',
 ]
 
index 82440c5..c3737fc 100644 (file)
@@ -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.thirdparty.mock import Mock
 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 @@ password: "SECRETSAUCE"
 
         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 @@ password: "SECRETSAUCE"
 
         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:
index b19c6d4..835e80a 100644 (file)
@@ -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
 
index 3980357..f7da018 100644 (file)
@@ -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 @@ class ParsedJSONResults(object):
                 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):
index 5c767d4..141a163 100644 (file)
@@ -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 @@ class ParsedJSONResultsTest(unittest.TestCase):
 });"""
 
     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())
index c673c8c..2c8aefe 100644 (file)
 #
 # 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 @@ class StatusServer:
     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
index 74be1ce..e798552 100644 (file)
@@ -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):