Code cleanup in ansible-test.
This commit is contained in:
parent
ed4fd9be67
commit
c495c92a6e
7 changed files with 17 additions and 13 deletions
3
changelogs/fragments/ansible-test-code-cleanup.yml
Normal file
3
changelogs/fragments/ansible-test-code-cleanup.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
bugfixes:
|
||||
- ansible-test - Use ``sys.exit`` instead of ``exit``.
|
||||
- ansible-test - Code cleanup.
|
|
@ -37,7 +37,8 @@ def main():
|
|||
found = False
|
||||
|
||||
if not found:
|
||||
exit('ERROR: Could not find `coverage` module. Did you use a virtualenv created without --system-site-packages or with the wrong interpreter?')
|
||||
sys.exit('ERROR: Could not find `coverage` module. '
|
||||
'Did you use a virtualenv created without --system-site-packages or with the wrong interpreter?')
|
||||
|
||||
if name == 'python.py':
|
||||
if sys.argv[1] == '-c':
|
||||
|
|
|
@ -191,7 +191,7 @@ def main():
|
|||
test_python_module(path, name, base_dir, messages)
|
||||
|
||||
if messages:
|
||||
exit(10)
|
||||
sys.exit(10)
|
||||
|
||||
def test_python_module(path, name, base_dir, messages):
|
||||
"""Test the given python module by importing it.
|
||||
|
|
|
@ -25,7 +25,7 @@ class BlacklistEntry:
|
|||
"""
|
||||
self.alternative = alternative
|
||||
self.modules_only = modules_only
|
||||
self.names = set(names) if names else None
|
||||
self.names = set(names) if names else set()
|
||||
self.ignore_paths = ignore_paths
|
||||
|
||||
def applies_to(self, path, name=None):
|
||||
|
|
|
@ -183,15 +183,15 @@ def main():
|
|||
display.review_warnings()
|
||||
except ApplicationWarning as ex:
|
||||
display.warning(u'%s' % ex)
|
||||
exit(0)
|
||||
sys.exit(0)
|
||||
except ApplicationError as ex:
|
||||
display.error(u'%s' % ex)
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
except KeyboardInterrupt:
|
||||
exit(2)
|
||||
sys.exit(2)
|
||||
except IOError as ex:
|
||||
if ex.errno == errno.EPIPE:
|
||||
exit(3)
|
||||
sys.exit(3)
|
||||
raise
|
||||
|
||||
|
||||
|
@ -675,7 +675,7 @@ def key_value(argparse, value): # type: (argparse_module, str) -> t.Tuple[str,
|
|||
if len(parts) != 2:
|
||||
raise argparse.ArgumentTypeError('"%s" must be in the format "key=value"' % value)
|
||||
|
||||
return tuple(parts)
|
||||
return parts[0], parts[1]
|
||||
|
||||
|
||||
# noinspection PyProtectedMember
|
||||
|
|
|
@ -14,6 +14,7 @@ from ..util import (
|
|||
find_executable,
|
||||
display,
|
||||
ConfigParser,
|
||||
ApplicationError,
|
||||
)
|
||||
|
||||
from ..docker_util import (
|
||||
|
@ -85,8 +86,7 @@ class VcenterProvider(CloudProvider):
|
|||
self._use_static_config()
|
||||
self._setup_static()
|
||||
else:
|
||||
display.error('Unknown vmware_test_platform: %s' % self.vmware_test_platform)
|
||||
exit(1)
|
||||
raise ApplicationError('Unknown vmware_test_platform: %s' % self.vmware_test_platform)
|
||||
|
||||
def get_docker_run_options(self):
|
||||
"""Get any additional options needed when delegating tests to a docker container.
|
||||
|
@ -161,8 +161,8 @@ class VcenterProvider(CloudProvider):
|
|||
|
||||
def _setup_static(self):
|
||||
if not os.path.exists(self.config_static_path):
|
||||
display.error('Configuration file does not exist: %s' % self.config_static_path)
|
||||
exit(1)
|
||||
raise ApplicationError('Configuration file does not exist: %s' % self.config_static_path)
|
||||
|
||||
parser = ConfigParser({
|
||||
'vcenter_port': '443',
|
||||
'vmware_proxy_host': '',
|
||||
|
|
|
@ -665,7 +665,7 @@ class SanityTest(ABC):
|
|||
"""A tuple of supported Python versions or None if the test does not depend on specific Python versions."""
|
||||
return tuple(python_version for python_version in SUPPORTED_PYTHON_VERSIONS if python_version.startswith('3.'))
|
||||
|
||||
def filter_targets(self, targets): # type: (t.List[TestTarget]) -> t.List[TestTarget]
|
||||
def filter_targets(self, targets): # type: (t.List[TestTarget]) -> t.List[TestTarget] # pylint: disable=unused-argument
|
||||
"""Return the given list of test targets, filtered to include only those relevant for the test."""
|
||||
if self.no_targets:
|
||||
return []
|
||||
|
|
Loading…
Reference in a new issue