Bug fixes and cleanup for ansible-test. (#45991)

* Remove unused imports.
* Clean up ConfigParser usage in ansible-test.
* Fix bare except statements in ansible-test.
* Miscellaneous cleanup from PyCharm inspections.
* Enable pylint no-self-use for ansible-test.
* Remove obsolete pylint ignores for Python 3.7.
* Fix shellcheck issuers under newer shellcheck.
* Use newer path for ansible-test.
* Fix issues in code-smell tests.
This commit is contained in:
Matt Clay 2018-09-21 11:38:22 -07:00 committed by GitHub
parent b60854357b
commit ac492476e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 36 additions and 128 deletions

View file

@ -5,7 +5,6 @@ from __future__ import absolute_import, print_function
import atexit
import contextlib
import errno
import filecmp
import fcntl
import inspect
import json
@ -32,6 +31,13 @@ except ImportError:
from abc import ABCMeta
ABC = ABCMeta('ABC', (), {})
try:
# noinspection PyCompatibility
from ConfigParser import SafeConfigParser as ConfigParser
except ImportError:
# noinspection PyCompatibility
from configparser import ConfigParser
DOCKER_COMPLETION = {}
coverage_path = '' # pylint: disable=locally-disabled, invalid-name
@ -117,10 +123,10 @@ def find_executable(executable, cwd=None, path=None, required=True):
match = executable
else:
if path is None:
path = os.environ.get('PATH', os.defpath)
path = os.environ.get('PATH', os.path.defpath)
if path:
path_dirs = path.split(os.pathsep)
path_dirs = path.split(os.path.pathsep)
seen_dirs = set()
for path_dir in path_dirs:
@ -197,7 +203,7 @@ def intercept_command(args, cmd, target_name, capture=False, env=None, data=None
coverage_file = os.path.abspath(os.path.join(inject_path, '..', 'output', '%s=%s=%s=%s=coverage' % (
args.command, target_name, args.coverage_label or 'local-%s' % version, 'python-%s' % version)))
env['PATH'] = inject_path + os.pathsep + env['PATH']
env['PATH'] = inject_path + os.path.pathsep + env['PATH']
env['ANSIBLE_TEST_PYTHON_VERSION'] = version
env['ANSIBLE_TEST_PYTHON_INTERPRETER'] = interpreter
@ -388,7 +394,7 @@ def common_environment():
"""Common environment used for executing all programs."""
env = dict(
LC_ALL='en_US.UTF-8',
PATH=os.environ.get('PATH', os.defpath),
PATH=os.environ.get('PATH', os.path.defpath),
)
required = (