New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make tests/jquery/run_jquery.py Python3 compatible #26035
Merged
+16
−12
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
Run py-modernize against tests/jquery/run_jquery.py
Attempt to make it py3 compatible
- Loading branch information
commit cc18718152afb2279b69c8aad48c298494612b6b
| @@ -4,15 +4,18 @@ | ||
| # License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| # file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| from __future__ import absolute_import | ||
| from __future__ import print_function | ||
| import os | ||
| import re | ||
| import subprocess | ||
| import sys | ||
| import BaseHTTPServer | ||
| import SimpleHTTPServer | ||
| import SocketServer | ||
| import six.moves.BaseHTTPServer | ||
| import six.moves.SimpleHTTPServer | ||
| import six.moves.socketserver | ||
| import threading | ||
| import urlparse | ||
| import six.moves.urllib.parse | ||
| import six | ||
|
|
||
| # List of jQuery modules that will be tested. | ||
| # TODO(gw): Disabled most of them as something has been | ||
| @@ -46,7 +49,7 @@ | ||
| TEST_SERVER_PORT = 8192 | ||
|
|
||
| # A regex for matching console.log output lines from the test runner. | ||
| REGEX_PATTERN = "^\[jQuery test\] \[([0-9]+)/([0-9]+)/([0-9]+)] (.*)" | ||
| REGEX_PATTERN = r"^\[jQuery test\] \[([0-9]+)/([0-9]+)/([0-9]+)] (.*)" | ||
|
||
|
|
||
|
|
||
| # The result of a single test group. | ||
| @@ -103,7 +106,7 @@ def run_servo(servo_exe, module): | ||
| break | ||
| line = line.rstrip() | ||
| try: | ||
| name, test_result = parse_line_to_result(line) | ||
| name, test_result = parse_line_to_result(line.decode('utf-8')) | ||
dralley
Author
Contributor
|
||
| yield name, test_result | ||
| except AttributeError: | ||
| pass | ||
| @@ -124,7 +127,7 @@ def read_existing_results(module): | ||
| # Write a set of results to file | ||
| def write_results(module, results): | ||
| with open(module_filename(module), 'w') as file: | ||
| for result in test_results.itervalues(): | ||
| for result in six.itervalues(test_results): | ||
| file.write(result.text + '\n') | ||
|
|
||
|
|
||
| @@ -135,24 +138,24 @@ def print_usage(): | ||
|
|
||
| # Run a simple HTTP server to serve up the jQuery test suite | ||
| def run_http_server(): | ||
| class ThreadingSimpleServer(SocketServer.ThreadingMixIn, | ||
| BaseHTTPServer.HTTPServer): | ||
| class ThreadingSimpleServer(six.moves.socketserver.ThreadingMixIn, | ||
| six.moves.BaseHTTPServer.HTTPServer): | ||
| allow_reuse_address = True | ||
|
|
||
| class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | ||
| class RequestHandler(six.moves.SimpleHTTPServer.SimpleHTTPRequestHandler): | ||
| # TODO(gw): HACK copy the fixed version from python | ||
| # main repo - due to https://bugs.python.org/issue23112 | ||
| def send_head(self): | ||
| path = self.translate_path(self.path) | ||
| f = None | ||
| if os.path.isdir(path): | ||
| parts = urlparse.urlsplit(self.path) | ||
| parts = six.moves.urllib.parse.urlsplit(self.path) | ||
| if not parts.path.endswith('/'): | ||
| # redirect browser - doing basically what apache does | ||
| self.send_response(301) | ||
| new_parts = (parts[0], parts[1], parts[2] + '/', | ||
| parts[3], parts[4]) | ||
| new_url = urlparse.urlunsplit(new_parts) | ||
| new_url = six.moves.urllib.parse.urlunsplit(new_parts) | ||
| self.send_header("Location", new_url) | ||
| self.end_headers() | ||
| return None | ||
| @@ -251,6 +254,7 @@ def log_message(self, format, *args): | ||
| print("\t{0} tests succeeded of {1} ({2:.2f}%)".format(individual_success, | ||
| individual_total, | ||
| 100.0 * individual_success / individual_total)) | ||
|
|
||
| if unexpected_count > 0: | ||
| sys.exit(1) | ||
| elif cmd == "update": | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
I changed this to a raw string literal