Update test_runner to be python3 compatible.
This CL was generated by 'python modernize', then some pylint disable messages were added. Bug: 1195981 Change-Id: I188226b2f674f32f18a1ee011c22e7ee82194790 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2818208 Reviewed-by: Peter Wen <wnwen@chromium.org> Commit-Queue: benjamin joyce <bjoyce@chromium.org> Cr-Commit-Position: refs/heads/master@{#875798}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
b0d18d9c1e
commit
d343ee76e0
build/android
pylib
base
base_test_result.pybase_test_result_unittest.pyenvironment_factory.pymock_environment.pymock_test_instance.pyoutput_manager.pyoutput_manager_factory.pyoutput_manager_test_case.pyresult_sink.pytest_collection.pytest_instance_factory.pytest_run_factory.py
constants
local
@ -4,7 +4,9 @@
|
||||
|
||||
"""Module containing base test results classes."""
|
||||
|
||||
from __future__ import absolute_import
|
||||
import threading
|
||||
import six
|
||||
|
||||
|
||||
class ResultType(object):
|
||||
@ -139,7 +141,7 @@ class TestRunResults(object):
|
||||
log = t.GetLog()
|
||||
if log:
|
||||
s.append('[%s] %s:' % (test_type, t))
|
||||
s.append(unicode(log, 'utf-8'))
|
||||
s.append(six.text_type(log, 'utf-8'))
|
||||
return '\n'.join(s)
|
||||
|
||||
def GetGtestForm(self):
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
"""Unittests for TestRunResults."""
|
||||
|
||||
from __future__ import absolute_import
|
||||
import unittest
|
||||
|
||||
from pylib.base.base_test_result import BaseTestResult
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from pylib import constants
|
||||
from pylib.local.device import local_device_environment
|
||||
from pylib.local.machine import local_machine_environment
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from pylib.base import environment
|
||||
|
||||
import mock # pylint: disable=import-error
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from pylib.base import test_instance
|
||||
|
||||
import mock # pylint: disable=import-error
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import contextlib
|
||||
import logging
|
||||
import os
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from pylib import constants
|
||||
from pylib.output import local_output_manager
|
||||
from pylib.output import remote_output_manager
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import os.path
|
||||
import unittest
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Copyright 2020 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
from __future__ import absolute_import
|
||||
import base64
|
||||
import cgi
|
||||
import json
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import threading
|
||||
|
||||
class TestCollection(object):
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from pylib.gtest import gtest_test_instance
|
||||
from pylib.instrumentation import instrumentation_test_instance
|
||||
from pylib.junit import junit_test_instance
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from pylib.gtest import gtest_test_instance
|
||||
from pylib.instrumentation import instrumentation_test_instance
|
||||
from pylib.junit import junit_test_instance
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
# pylint: disable=W0212
|
||||
|
||||
from __future__ import absolute_import
|
||||
import collections
|
||||
import glob
|
||||
import logging
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import contextlib
|
||||
import os
|
||||
import sys
|
||||
|
@ -3,14 +3,15 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import six
|
||||
import pylib.constants as constants
|
||||
import pylib.constants.host_paths as host_paths
|
||||
|
||||
|
||||
# This map corresponds to the binprefix of NDK prebuilt toolchains for various
|
||||
# target CPU architectures. Note that 'x86_64' and 'x64' are the same.
|
||||
_EXPECTED_NDK_TOOL_SUBDIR_MAP = {
|
||||
@ -40,7 +41,7 @@ class HostPathsTest(unittest.TestCase):
|
||||
self.assertEqual(host_paths.GetAaptPath(), _EXPECTED_AAPT_PATH)
|
||||
|
||||
def test_ToolPath(self):
|
||||
for cpu_arch, binprefix in _EXPECTED_NDK_TOOL_SUBDIR_MAP.iteritems():
|
||||
for cpu_arch, binprefix in six.iteritems(_EXPECTED_NDK_TOOL_SUBDIR_MAP):
|
||||
expected_binprefix = os.path.join(constants.ANDROID_NDK_ROOT, binprefix)
|
||||
expected_path = expected_binprefix + 'foo'
|
||||
self.assertEqual(host_paths.ToolPath('foo', cpu_arch), expected_path)
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import datetime
|
||||
import functools
|
||||
import logging
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import contextlib
|
||||
import collections
|
||||
import itertools
|
||||
@ -13,6 +14,7 @@ import subprocess
|
||||
import shutil
|
||||
import time
|
||||
|
||||
from six.moves import range # pylint: disable=redefined-builtin
|
||||
from devil import base_error
|
||||
from devil.android import crash_handler
|
||||
from devil.android import device_errors
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
# pylint: disable=protected-access
|
||||
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
# pylint: disable=protected-access
|
||||
|
||||
from __future__ import absolute_import
|
||||
import unittest
|
||||
|
||||
from pylib.base import base_test_result
|
||||
|
@ -2,8 +2,10 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
|
||||
from six.moves import range # pylint: disable=redefined-builtin
|
||||
from devil.android import device_errors
|
||||
from devil.android.sdk import intent
|
||||
from pylib import constants
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
# pylint: disable=protected-access
|
||||
|
||||
from __future__ import absolute_import
|
||||
import unittest
|
||||
|
||||
from pylib.base import base_test_result
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import contextlib
|
||||
import json
|
||||
import logging
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
"""Basic .ini encoding and decoding."""
|
||||
|
||||
from __future__ import absolute_import
|
||||
import contextlib
|
||||
import os
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
# found in the LICENSE file.
|
||||
"""Tests for ini.py."""
|
||||
|
||||
from __future__ import absolute_import
|
||||
import textwrap
|
||||
import unittest
|
||||
|
||||
|
@ -2,8 +2,10 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
|
||||
from six.moves import range # pylint: disable=redefined-builtin
|
||||
from devil import base_error
|
||||
from devil.android import device_errors
|
||||
from devil.android import device_utils
|
||||
|
@ -2,9 +2,11 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import json
|
||||
import time
|
||||
|
||||
from six.moves import range # pylint: disable=redefined-builtin
|
||||
from devil.android import forwarder
|
||||
from devil.android import ports
|
||||
from pylib.base import test_server
|
||||
@ -25,7 +27,7 @@ def _WaitUntil(predicate, max_attempts=5):
|
||||
Whether the provided predicate was satisfied once (before the timeout).
|
||||
"""
|
||||
sleep_time_sec = 0.025
|
||||
for _ in xrange(1, max_attempts):
|
||||
for _ in range(1, max_attempts):
|
||||
if predicate():
|
||||
return True
|
||||
time.sleep(sleep_time_sec)
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import devil_chromium
|
||||
from pylib import constants
|
||||
from pylib.base import environment
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
import collections
|
||||
import json
|
||||
import logging
|
||||
@ -12,6 +13,7 @@ import subprocess
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
from six.moves import range # pylint: disable=redefined-builtin
|
||||
from pylib import constants
|
||||
from pylib.base import base_test_result
|
||||
from pylib.base import test_run
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
# pylint: disable=protected-access
|
||||
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import unittest
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
"""Runs all types of tests from one unified interface."""
|
||||
|
||||
from __future__ import absolute_import
|
||||
import argparse
|
||||
import collections
|
||||
import contextlib
|
||||
@ -26,6 +27,8 @@ import unittest
|
||||
# See http://crbug.com/724524 and https://bugs.python.org/issue7980.
|
||||
import _strptime # pylint: disable=unused-import
|
||||
|
||||
# pylint: disable=redefined-builtin
|
||||
from six.moves import range # Needed for python 3 compatibility.
|
||||
# pylint: disable=ungrouped-imports
|
||||
from pylib.constants import host_paths
|
||||
|
||||
@ -700,10 +703,11 @@ def AddMonkeyTestOptions(parser):
|
||||
|
||||
parser = parser.add_argument_group('monkey arguments')
|
||||
|
||||
parser.add_argument(
|
||||
'--browser',
|
||||
required=True, choices=constants.PACKAGE_INFO.keys(),
|
||||
metavar='BROWSER', help='Browser under test.')
|
||||
parser.add_argument('--browser',
|
||||
required=True,
|
||||
choices=list(constants.PACKAGE_INFO.keys()),
|
||||
metavar='BROWSER',
|
||||
help='Browser under test.')
|
||||
parser.add_argument(
|
||||
'--category',
|
||||
nargs='*', dest='categories', default=[],
|
||||
@ -728,11 +732,12 @@ def AddPythonTestOptions(parser):
|
||||
|
||||
parser = parser.add_argument_group('python arguments')
|
||||
|
||||
parser.add_argument(
|
||||
'-s', '--suite',
|
||||
dest='suite_name', metavar='SUITE_NAME',
|
||||
choices=constants.PYTHON_UNIT_TEST_SUITES.keys(),
|
||||
help='Name of the test suite to run.')
|
||||
parser.add_argument('-s',
|
||||
'--suite',
|
||||
dest='suite_name',
|
||||
metavar='SUITE_NAME',
|
||||
choices=list(constants.PYTHON_UNIT_TEST_SUITES.keys()),
|
||||
help='Name of the test suite to run.')
|
||||
|
||||
|
||||
def _CreateClassToFileNameDict(test_apk):
|
||||
@ -963,8 +968,8 @@ def RunTestsInPlatformMode(args, result_sink_client=None):
|
||||
with out_manager, json_finalizer():
|
||||
with json_writer(), logcats_uploader, env, test_instance, test_run:
|
||||
|
||||
repetitions = (xrange(args.repeat + 1) if args.repeat >= 0
|
||||
else itertools.count())
|
||||
repetitions = (range(args.repeat +
|
||||
1) if args.repeat >= 0 else itertools.count())
|
||||
result_counts = collections.defaultdict(
|
||||
lambda: collections.defaultdict(int))
|
||||
iteration_count = 0
|
||||
|
@ -95,7 +95,6 @@
|
||||
../../third_party/catapult/devil/devil/utils/timeout_retry.py
|
||||
../../third_party/catapult/devil/devil/utils/watchdog_timer.py
|
||||
../../third_party/catapult/devil/devil/utils/zip_utils.py
|
||||
../../third_party/catapult/third_party/six/six.py
|
||||
../../third_party/colorama/src/colorama/__init__.py
|
||||
../../third_party/colorama/src/colorama/ansi.py
|
||||
../../third_party/colorama/src/colorama/ansitowin32.py
|
||||
|
Reference in New Issue
Block a user