From 04603693013eed712d51d4c90144f22f48f4270b Mon Sep 17 00:00:00 2001 From: "jbudorick@chromium.org" Date: Wed, 12 Feb 2014 23:05:36 +0000 Subject: [PATCH] [Android] Lint pylib/host_driven. BUG=168518 Review URL: https://codereview.chromium.org/159853010 git-svn-id: http://src.chromium.org/svn/trunk/src/build@250822 4ff67af0-8c30-449e-8e8b-ad334ec8d88c --- android/pylib/host_driven/setup.py | 6 ++--- android/pylib/host_driven/test_case.py | 27 ++++++++++++------- .../pylib/host_driven/test_info_collection.py | 11 +++++--- android/pylib/host_driven/test_runner.py | 3 +-- .../pylib/host_driven/tests_annotations.py | 1 + 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/android/pylib/host_driven/setup.py b/android/pylib/host_driven/setup.py index a087bf148..d48f90862 100644 --- a/android/pylib/host_driven/setup.py +++ b/android/pylib/host_driven/setup.py @@ -9,9 +9,9 @@ import os import sys import types -import test_case -import test_info_collection -import test_runner +from pylib.host_driven import test_case +from pylib.host_driven import test_info_collection +from pylib.host_driven import test_runner def _GetPythonFiles(root, files): diff --git a/android/pylib/host_driven/test_case.py b/android/pylib/host_driven/test_case.py index 8ff94083a..3ee4fe7a9 100644 --- a/android/pylib/host_driven/test_case.py +++ b/android/pylib/host_driven/test_case.py @@ -25,7 +25,6 @@ import os import time from pylib import android_commands -from pylib import constants from pylib import forwarder from pylib import valgrind_tools from pylib.base import base_test_result @@ -49,21 +48,28 @@ class HostDrivenTestCase(object): test_name: The name of the method to run as the test. instrumentation_options: An InstrumentationOptions object. """ - self.test_name = test_name class_name = self.__class__.__name__ - self.qualified_name = '%s.%s' % (class_name, self.test_name) - # Use tagged_name when creating results, so that we can identify host-driven - # tests in the overall results. - self.tagged_name = '%s_%s' % (self._HOST_DRIVEN_TAG, self.qualified_name) - + self.adb = None + self.cleanup_test_files = False + self.device_id = '' + self.has_forwarded_ports = False self.instrumentation_options = instrumentation_options self.ports_to_forward = [] - self.has_forwarded_ports = False + self.push_deps = False + self.shard_index = 0 + + # Use tagged_name when creating results, so that we can identify host-driven + # tests in the overall results. + self.test_name = test_name + self.qualified_name = '%s.%s' % (class_name, self.test_name) + self.tagged_name = '%s_%s' % (self._HOST_DRIVEN_TAG, self.qualified_name) # TODO(bulach): make ports_to_forward not optional and move the Forwarder # mapping here. def SetUp(self, device, shard_index, push_deps, - cleanup_test_files, ports_to_forward=[]): + cleanup_test_files, ports_to_forward=None): + if not ports_to_forward: + ports_to_forward = [] self.device_id = device self.shard_index = shard_index self.adb = android_commands.AndroidCommands(self.device_id) @@ -85,7 +91,8 @@ class HostDrivenTestCase(object): # Get the test method on the derived class and execute it return getattr(self, self.test_name)() - def __GetHostForwarderLog(self): + @staticmethod + def __GetHostForwarderLog(): return ('-- Begin Full HostForwarder log\n' '%s\n' '--End Full HostForwarder log\n' % forwarder.Forwarder.GetHostLog()) diff --git a/android/pylib/host_driven/test_info_collection.py b/android/pylib/host_driven/test_info_collection.py index a857d3c1c..b0b76a981 100644 --- a/android/pylib/host_driven/test_info_collection.py +++ b/android/pylib/host_driven/test_info_collection.py @@ -7,7 +7,7 @@ import logging import os -import tests_annotations +from pylib.host_driven import tests_annotations class TestInfo(object): @@ -22,7 +22,8 @@ class TestInfo(object): self.set_up = set_up self.tear_down = tear_down - def _GetQualifiedName(self, runnable): + @staticmethod + def _GetQualifiedName(runnable): """Helper method to infer a runnable's name and module name. Many filters and lists presuppose a format of module_name.testMethodName. @@ -102,7 +103,8 @@ class TestInfoCollection(object): return available_tests - def _AnnotationIncludesTest(self, test_info, annotation_filter_list): + @staticmethod + def _AnnotationIncludesTest(test_info, annotation_filter_list): """Checks whether a given test represented by test_info matches annotation. Args: @@ -128,7 +130,8 @@ class TestInfoCollection(object): return True return False - def _NameFilterIncludesTest(self, test_info, name_filter): + @staticmethod + def _NameFilterIncludesTest(test_info, name_filter): """Checks whether a name filter matches a given test_info's method name. This is a case-sensitive, substring comparison: 'Foo' will match methods diff --git a/android/pylib/host_driven/test_runner.py b/android/pylib/host_driven/test_runner.py index 53fd70f3d..c7d6ed1ba 100644 --- a/android/pylib/host_driven/test_runner.py +++ b/android/pylib/host_driven/test_runner.py @@ -11,10 +11,9 @@ import traceback from pylib.base import base_test_result from pylib.base import base_test_runner +from pylib.host_driven import test_case from pylib.instrumentation import test_result -import test_case - class HostDrivenExceptionTestResult(test_result.InstrumentationTestResult): """Test result corresponding to a python exception in a host-driven test.""" diff --git a/android/pylib/host_driven/tests_annotations.py b/android/pylib/host_driven/tests_annotations.py index d5f557de8..533114065 100644 --- a/android/pylib/host_driven/tests_annotations.py +++ b/android/pylib/host_driven/tests_annotations.py @@ -3,6 +3,7 @@ # found in the LICENSE file. """Annotations for host-driven tests.""" +# pylint: disable=W0212 import os