diff --git a/test/runner/lib/changes.py b/test/runner/lib/changes.py index 8b66478fd59..890dd223a3a 100644 --- a/test/runner/lib/changes.py +++ b/test/runner/lib/changes.py @@ -39,11 +39,7 @@ class InvalidBranch(ApplicationError): class ChangeDetectionNotSupported(ApplicationError): """Exception for cases where change detection is not supported.""" - def __init__(self, message): - """ - :type message: str - """ - super(ChangeDetectionNotSupported, self).__init__(message) + pass class ShippableChanges(object): diff --git a/test/runner/lib/classification.py b/test/runner/lib/classification.py index b576cfacb83..b6d10920fb7 100644 --- a/test/runner/lib/classification.py +++ b/test/runner/lib/classification.py @@ -77,7 +77,7 @@ def categorize_changes(paths, verbose_command=None): # identify targeted integration tests (those which only target a single integration command) if 'integration' in verbose_command and tests.get(verbose_command): - if not any('integration' in command for command in tests.keys() if command != verbose_command): + if not any('integration' in command for command in tests if command != verbose_command): result += ' (targeted)' else: result = '%s' % tests @@ -91,7 +91,7 @@ def categorize_changes(paths, verbose_command=None): if any(t == 'all' for t in commands[command]): commands[command] = set(['all']) - commands = dict((c, sorted(commands[c])) for c in commands.keys() if commands[c]) + commands = dict((c, sorted(commands[c])) for c in commands if commands[c]) return commands diff --git a/test/runner/lib/executor.py b/test/runner/lib/executor.py index 2b1f39768f7..79dc101ede7 100644 --- a/test/runner/lib/executor.py +++ b/test/runner/lib/executor.py @@ -29,7 +29,6 @@ from lib.manage_ci import ( ) from lib.util import ( - CommonConfig, EnvironmentConfig, ApplicationWarning, ApplicationError, @@ -83,10 +82,6 @@ from lib.test import ( TestSkipped, ) -from lib.metadata import ( - Metadata, -) - SUPPORTED_PYTHON_VERSIONS = ( '2.6', '2.7', @@ -478,9 +473,9 @@ def command_integration_filtered(args, targets): run_command(args, ['ssh', '-o', 'BatchMode=yes', 'localhost', 'id'], capture=True) display.info('SSH service responded.') break - except SubprocessError as ex: + except SubprocessError: if i == max_tries: - raise ex + raise seconds = 3 display.warning('SSH service not responding. Waiting %d second(s) before checking again.' % seconds) time.sleep(seconds) diff --git a/test/runner/lib/git.py b/test/runner/lib/git.py index 07a4245958c..5cea4f8c66d 100644 --- a/test/runner/lib/git.py +++ b/test/runner/lib/git.py @@ -84,7 +84,7 @@ class Git(object): """ output = self.run_git(cmd).strip(separator) - if len(output) == 0: + if not output: return [] return output.split(separator) diff --git a/test/runner/lib/http.py b/test/runner/lib/http.py index 554fdf93d64..f374c0635e6 100644 --- a/test/runner/lib/http.py +++ b/test/runner/lib/http.py @@ -10,7 +10,7 @@ import json try: from urllib import urlencode except ImportError: - # noinspection PyCompatibility,PyUnresolvedReferences,PyUnresolvedReferences + # noinspection PyCompatibility, PyUnresolvedReferences from urllib.parse import urlencode # pylint: disable=locally-disabled, import-error, no-name-in-module from lib.util import ( diff --git a/test/runner/lib/import_analysis.py b/test/runner/lib/import_analysis.py index 94f31f4d26b..5ecfff8635f 100644 --- a/test/runner/lib/import_analysis.py +++ b/test/runner/lib/import_analysis.py @@ -4,7 +4,6 @@ from __future__ import absolute_import, print_function import ast import os -import uuid from lib.util import ( display, @@ -110,7 +109,7 @@ def get_python_module_utils_imports(compile_targets): display.info('%s reports imports from parent package %s' % (virtual_util, parent_package), verbosity=6) for module_util in sorted(imports): - if not len(imports[module_util]): + if not imports[module_util]: display.warning('No imports found which use the "%s" module_util.' % module_util) return imports diff --git a/test/runner/lib/metadata.py b/test/runner/lib/metadata.py index 64c6c8a4d34..405132dbf38 100644 --- a/test/runner/lib/metadata.py +++ b/test/runner/lib/metadata.py @@ -9,7 +9,6 @@ from lib.util import ( from lib.diff import ( parse_diff, - FileDiff, ) diff --git a/test/runner/lib/sanity.py b/test/runner/lib/sanity.py index 93405b23ae5..a8294dcbbf8 100644 --- a/test/runner/lib/sanity.py +++ b/test/runner/lib/sanity.py @@ -673,22 +673,13 @@ def collect_code_smell_tests(): skip_tests = skip_fd.read().splitlines() paths = glob.glob('test/sanity/code-smell/*') - paths = sorted(p for p in paths - if os.access(p, os.X_OK) - and os.path.isfile(p) - and os.path.basename(p) not in skip_tests) + paths = sorted(p for p in paths if os.access(p, os.X_OK) and os.path.isfile(p) and os.path.basename(p) not in skip_tests) tests = tuple(SanityFunc(os.path.splitext(os.path.basename(p))[0], command_sanity_code_smell, script=p, intercept=False) for p in paths) return tests -def sanity_init(): - """Initialize full sanity test list (includes code-smell scripts determined at runtime).""" - global SANITY_TESTS # pylint: disable=locally-disabled, global-statement - SANITY_TESTS = tuple(sorted(SANITY_TESTS + collect_code_smell_tests(), key=lambda k: k.name)) - - def sanity_get_tests(): """ :rtype: tuple(SanityFunc) @@ -730,17 +721,7 @@ class SanityFailure(TestFailure): class SanityMessage(TestMessage): """Single sanity test message for one file.""" - def __init__(self, message, path, line=0, column=0, level='error', code=None, confidence=None): - """ - :type message: str - :type path: str - :type line: int - :type column: int - :type level: str - :type code: str | None - :type confidence: int | None - """ - super(SanityMessage, self).__init__(message, path, line, column, level, code, confidence) + pass class SanityTargets(object): @@ -788,3 +769,9 @@ SANITY_TESTS = ( SanityFunc('validate-modules', command_sanity_validate_modules, intercept=False), SanityFunc('ansible-doc', command_sanity_ansible_doc), ) + + +def sanity_init(): + """Initialize full sanity test list (includes code-smell scripts determined at runtime).""" + global SANITY_TESTS # pylint: disable=locally-disabled, global-statement + SANITY_TESTS = tuple(sorted(SANITY_TESTS + collect_code_smell_tests(), key=lambda k: k.name)) diff --git a/test/runner/lib/target.py b/test/runner/lib/target.py index f6051ec73ee..fa0b0cdf921 100644 --- a/test/runner/lib/target.py +++ b/test/runner/lib/target.py @@ -323,8 +323,8 @@ class CompletionTarget(object): def __eq__(self, other): if isinstance(other, CompletionTarget): return self.__repr__() == other.__repr__() - else: - return False + + return False def __ne__(self, other): return not self.__eq__(other) diff --git a/test/runner/lib/test.py b/test/runner/lib/test.py index f38d0f340ef..e07e813b4ca 100644 --- a/test/runner/lib/test.py +++ b/test/runner/lib/test.py @@ -192,14 +192,6 @@ class TestResult(object): class TestSuccess(TestResult): """Test success.""" - def __init__(self, command, test, python_version=None): - """ - :type command: str - :type test: str - :type python_version: str - """ - super(TestSuccess, self).__init__(command, test, python_version) - def write_junit(self, args): """ :type args: TestConfig @@ -211,14 +203,6 @@ class TestSuccess(TestResult): class TestSkipped(TestResult): """Test skipped.""" - def __init__(self, command, test, python_version=None): - """ - :type command: str - :type test: str - :type python_version: str - """ - super(TestSkipped, self).__init__(command, test, python_version) - def write_console(self): """Write results to console.""" display.info('No tests applicable.', verbosity=1) diff --git a/test/runner/lib/thread.py b/test/runner/lib/thread.py index cf7d6a36c40..e40ed269bdf 100644 --- a/test/runner/lib/thread.py +++ b/test/runner/lib/thread.py @@ -19,6 +19,7 @@ class WrappedThread(threading.Thread): """ :type action: () -> any """ + # noinspection PyOldStyleClasses super(WrappedThread, self).__init__() self._result = queue.Queue() self.action = action diff --git a/test/runner/lib/util.py b/test/runner/lib/util.py index 74942d4b573..358c54a4d7f 100644 --- a/test/runner/lib/util.py +++ b/test/runner/lib/util.py @@ -372,20 +372,12 @@ class Display(object): class ApplicationError(Exception): """General application error.""" - def __init__(self, message=None): - """ - :type message: str | None - """ - super(ApplicationError, self).__init__(message) + pass class ApplicationWarning(Exception): """General application warning which interrupts normal program flow.""" - def __init__(self, message=None): - """ - :type message: str | None - """ - super(ApplicationWarning, self).__init__(message) + pass class SubprocessError(ApplicationError): diff --git a/test/runner/retry.py b/test/runner/retry.py index 49721316f01..bc1c140a162 100755 --- a/test/runner/retry.py +++ b/test/runner/retry.py @@ -4,6 +4,7 @@ from __future__ import absolute_import, print_function +# noinspection PyCompatibility import argparse import errno import os diff --git a/test/runner/test.py b/test/runner/test.py index 801f07f9634..62275bad850 100755 --- a/test/runner/test.py +++ b/test/runner/test.py @@ -391,7 +391,6 @@ def add_lint(parser): help='exit successfully on failed tests after saving results') - def add_changes(parser, argparse): """ :type parser: argparse.ArgumentParser diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt index 8a787a5c341..3a462537ec6 100644 --- a/test/sanity/pep8/legacy-files.txt +++ b/test/sanity/pep8/legacy-files.txt @@ -964,8 +964,6 @@ test/integration/gce_credentials.py test/integration/setup_gce.py test/integration/targets/async/library/async_test.py test/integration/targets/uri/files/testserver.py -test/runner/lib/sanity.py -test/runner/test.py test/sanity/code-smell/ansible-var-precedence-check.py test/sanity/validate-modules/module_args.py test/sanity/validate-modules/schema.py