From 9763b9f4f2053fc0c9b6512339d2089c27944f88 Mon Sep 17 00:00:00 2001 From: "jbudorick@chromium.org" Date: Tue, 11 Feb 2014 23:21:15 +0000 Subject: [PATCH] [Android] Lint pylib/base. BUG=168518 Review URL: https://codereview.chromium.org/156603003 git-svn-id: http://src.chromium.org/svn/trunk/src/build@250545 4ff67af0-8c30-449e-8e8b-ad334ec8d88c --- android/pylib/base/base_test_result_unittest.py | 6 +++--- android/pylib/base/base_test_runner.py | 7 +------ android/pylib/base/test_dispatcher.py | 7 ++++--- android/pylib/base/test_dispatcher_unittest.py | 8 +++++--- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/android/pylib/base/base_test_result_unittest.py b/android/pylib/base/base_test_result_unittest.py index f038b3199..591b8f386 100644 --- a/android/pylib/base/base_test_result_unittest.py +++ b/android/pylib/base/base_test_result_unittest.py @@ -6,9 +6,9 @@ import unittest -from base_test_result import BaseTestResult -from base_test_result import TestRunResults -from base_test_result import ResultType +from pylib.base.base_test_result import BaseTestResult +from pylib.base.base_test_result import TestRunResults +from pylib.base.base_test_result import ResultType class TestTestRunResults(unittest.TestCase): diff --git a/android/pylib/base/base_test_runner.py b/android/pylib/base/base_test_runner.py index 2688a6fbf..44a457bff 100644 --- a/android/pylib/base/base_test_runner.py +++ b/android/pylib/base/base_test_runner.py @@ -4,15 +4,10 @@ """Base class for running tests on a single device.""" -import contextlib -import httplib import logging -import os -import tempfile import time from pylib import android_commands -from pylib import constants from pylib import ports from pylib.chrome_test_server_spawner import SpawningServer from pylib.forwarder import Forwarder @@ -181,7 +176,7 @@ class BaseTestRunner(object): # well as IsHttpServerConnectable(). spawning_server.Start() should also # block until the server is ready. # Try 3 times to launch test spawner server. - for i in xrange(0, 3): + for _ in xrange(0, 3): self.test_server_spawner_port = ports.AllocateTestServerPort() self._ForwardPorts( [(self.test_server_spawner_port, self.test_server_spawner_port)]) diff --git a/android/pylib/base/test_dispatcher.py b/android/pylib/base/test_dispatcher.py index 11374bbf4..5f68a7ff4 100644 --- a/android/pylib/base/test_dispatcher.py +++ b/android/pylib/base/test_dispatcher.py @@ -20,11 +20,10 @@ import threading from pylib import android_commands from pylib import constants +from pylib.base import base_test_result from pylib.utils import reraiser_thread from pylib.utils import watchdog_timer -import base_test_result - DEFAULT_TIMEOUT = 7 * 60 # seven minutes @@ -69,7 +68,9 @@ class _TestCollection(object): tests: List of tests to put in the collection. """ - def __init__(self, tests=[]): + def __init__(self, tests=None): + if not tests: + tests = [] self._lock = threading.Lock() self._tests = [] self._tests_in_progress = 0 diff --git a/android/pylib/base/test_dispatcher_unittest.py b/android/pylib/base/test_dispatcher_unittest.py index c6078dbdf..1409b5bbc 100644 --- a/android/pylib/base/test_dispatcher_unittest.py +++ b/android/pylib/base/test_dispatcher_unittest.py @@ -3,6 +3,8 @@ # found in the LICENSE file. """Unittests for test_dispatcher.py.""" +# pylint: disable=R0201 +# pylint: disable=W0212 import os import sys @@ -15,10 +17,10 @@ sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), from pylib import android_commands android_commands.GetAttachedDevices = lambda: ['0', '1'] from pylib import constants +from pylib.base import base_test_result +from pylib.base import test_dispatcher from pylib.utils import watchdog_timer -import base_test_result -import test_dispatcher class TestException(Exception): @@ -191,7 +193,7 @@ class TestShard(unittest.TestCase): android_commands.GetAttachedDevices = lambda: [] try: with self.assertRaises(AssertionError): - results, exit_code = TestShard._RunShard(MockRunner) + _results, _exit_code = TestShard._RunShard(MockRunner) finally: android_commands.GetAttachedDevices = attached_devices