summaryrefslogtreecommitdiff
path: root/test/lib/ansible_test/_internal
diff options
context:
space:
mode:
authorMatt Clay <mclay@redhat.com>2021-08-11 11:47:18 -0700
committerGitHub <noreply@github.com>2021-08-11 11:47:18 -0700
commitca2d2c5f38f2d4d4e6f6eed4f209520289c6f322 (patch)
tree772a0c20cb3165632190b0190b82afb1ae9c8a3e /test/lib/ansible_test/_internal
parent39605cdcce9745c6b193d6ae640f1f053a1d47cc (diff)
downloadansible-ca2d2c5f38f2d4d4e6f6eed4f209520289c6f322.tar.gz
ansible-test - Cleanup to prepare for pylint update. (#75469)
* ansible-test - Fix use of abstractproperty * ansible-test - Use dict.items() where possible. * ansible-test - Remove unused code. * ansible-test - Cleanup issues reported by pylint. * ansible-test - Use dict.items() where possible. * ansible-test - Use generator.
Diffstat (limited to 'test/lib/ansible_test/_internal')
-rw-r--r--test/lib/ansible_test/_internal/classification/__init__.py14
-rw-r--r--test/lib/ansible_test/_internal/classification/csharp.py4
-rw-r--r--test/lib/ansible_test/_internal/classification/powershell.py4
-rw-r--r--test/lib/ansible_test/_internal/classification/python.py12
-rw-r--r--test/lib/ansible_test/_internal/commands/sanity/__init__.py2
-rw-r--r--test/lib/ansible_test/_internal/core_ci.py4
-rw-r--r--test/lib/ansible_test/_internal/io.py8
-rw-r--r--test/lib/ansible_test/_internal/provider/layout/collection.py3
8 files changed, 24 insertions, 27 deletions
diff --git a/test/lib/ansible_test/_internal/classification/__init__.py b/test/lib/ansible_test/_internal/classification/__init__.py
index 607c25098d..69c594ae29 100644
--- a/test/lib/ansible_test/_internal/classification/__init__.py
+++ b/test/lib/ansible_test/_internal/classification/__init__.py
@@ -156,17 +156,17 @@ def categorize_changes(args, paths, verbose_command=None):
if none_count > 0 and args.verbosity < 2:
display.notice('Omitted %d file(s) that triggered no tests.' % none_count)
- for command in commands:
- commands[command].discard('none')
+ for command, targets in commands.items():
+ targets.discard('none')
- if any(target == 'all' for target in commands[command]):
+ if any(target == 'all' for target in targets):
commands[command] = set(['all'])
- commands = dict((c, sorted(commands[c])) for c in commands if commands[c])
- focused_commands = dict((c, sorted(focused_commands[c])) for c in focused_commands)
+ commands = dict((c, sorted(targets)) for c, targets in commands.items() if targets)
+ focused_commands = dict((c, sorted(targets)) for c, targets in focused_commands.items())
- for command in commands:
- if commands[command] == ['all']:
+ for command, targets in commands.items():
+ if targets == ['all']:
commands[command] = [] # changes require testing all targets, do not filter targets
changes = ChangeDescription()
diff --git a/test/lib/ansible_test/_internal/classification/csharp.py b/test/lib/ansible_test/_internal/classification/csharp.py
index bc29cee4b1..a6229ec0f3 100644
--- a/test/lib/ansible_test/_internal/classification/csharp.py
+++ b/test/lib/ansible_test/_internal/classification/csharp.py
@@ -41,8 +41,8 @@ def get_csharp_module_utils_imports(powershell_targets, csharp_targets):
imports = dict([(module_util, set()) for module_util in module_utils])
- for target_path in imports_by_target_path:
- for module_util in imports_by_target_path[target_path]:
+ for target_path, modules in imports_by_target_path.items():
+ for module_util in modules:
imports[module_util].add(target_path)
for module_util in sorted(imports):
diff --git a/test/lib/ansible_test/_internal/classification/powershell.py b/test/lib/ansible_test/_internal/classification/powershell.py
index e0be660947..67e9efa778 100644
--- a/test/lib/ansible_test/_internal/classification/powershell.py
+++ b/test/lib/ansible_test/_internal/classification/powershell.py
@@ -37,8 +37,8 @@ def get_powershell_module_utils_imports(powershell_targets):
imports = dict([(module_util, set()) for module_util in module_utils])
- for target_path in imports_by_target_path:
- for module_util in imports_by_target_path[target_path]:
+ for target_path, modules in imports_by_target_path.items():
+ for module_util in modules:
imports[module_util].add(target_path)
for module_util in sorted(imports):
diff --git a/test/lib/ansible_test/_internal/classification/python.py b/test/lib/ansible_test/_internal/classification/python.py
index cc6d05e0dd..0ce0367561 100644
--- a/test/lib/ansible_test/_internal/classification/python.py
+++ b/test/lib/ansible_test/_internal/classification/python.py
@@ -97,17 +97,17 @@ def get_python_module_utils_imports(compile_targets):
module_util_imports.remove(module_util)
# add recursive imports to all path entries which import this module_util
- for target_path in imports_by_target_path:
- if module_util in imports_by_target_path[target_path]:
+ for target_path, modules in imports_by_target_path.items():
+ if module_util in modules:
for module_util_import in sorted(module_util_imports):
- if module_util_import not in imports_by_target_path[target_path]:
+ if module_util_import not in modules:
display.info('%s inherits import %s via %s' % (target_path, module_util_import, module_util), verbosity=6)
- imports_by_target_path[target_path].add(module_util_import)
+ modules.add(module_util_import)
imports = dict([(module_util, set()) for module_util in module_utils | virtual_utils])
- for target_path in imports_by_target_path:
- for module_util in imports_by_target_path[target_path]:
+ for target_path, modules in imports_by_target_path.items():
+ for module_util in modules:
imports[module_util].add(target_path)
# for purposes of mapping module_utils to paths, treat imports of virtual utils the same as the parent package
diff --git a/test/lib/ansible_test/_internal/commands/sanity/__init__.py b/test/lib/ansible_test/_internal/commands/sanity/__init__.py
index 1b7c468413..58c838e862 100644
--- a/test/lib/ansible_test/_internal/commands/sanity/__init__.py
+++ b/test/lib/ansible_test/_internal/commands/sanity/__init__.py
@@ -1050,6 +1050,6 @@ def sanity_init():
import_plugins('commands/sanity')
sanity_plugins = {} # type: t.Dict[str, t.Type[SanityFunc]]
load_plugins(SanityFunc, sanity_plugins)
- sanity_tests = tuple([plugin() for plugin in sanity_plugins.values() if data_context().content.is_ansible or not plugin.ansible_only])
+ sanity_tests = tuple(plugin() for plugin in sanity_plugins.values() if data_context().content.is_ansible or not plugin.ansible_only)
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/lib/ansible_test/_internal/core_ci.py b/test/lib/ansible_test/_internal/core_ci.py
index bd03335c42..a48fdbe0e1 100644
--- a/test/lib/ansible_test/_internal/core_ci.py
+++ b/test/lib/ansible_test/_internal/core_ci.py
@@ -126,13 +126,13 @@ class AnsibleCoreCI:
else:
self.provider = None
- for candidate in self.PROVIDERS:
+ for candidate, platforms in self.PROVIDERS.items():
choices = [
platform,
'%s arch=%s' % (platform, arch),
]
- if any(choice in self.PROVIDERS[candidate] for choice in choices):
+ if any(choice in platforms for choice in choices):
# assign default provider based on platform
self.provider = candidate
break
diff --git a/test/lib/ansible_test/_internal/io.py b/test/lib/ansible_test/_internal/io.py
index da69da4094..3ceda56681 100644
--- a/test/lib/ansible_test/_internal/io.py
+++ b/test/lib/ansible_test/_internal/io.py
@@ -87,8 +87,8 @@ def open_binary_file(path, mode='rb'): # type: (str, str) -> t.BinaryIO
class SortedSetEncoder(json.JSONEncoder):
"""Encode sets as sorted lists."""
- def default(self, obj): # pylint: disable=method-hidden, arguments-differ
- if isinstance(obj, set):
- return sorted(obj)
+ def default(self, o):
+ if isinstance(o, set):
+ return sorted(o)
- return json.JSONEncoder.default(self, obj)
+ return json.JSONEncoder.default(self, o)
diff --git a/test/lib/ansible_test/_internal/provider/layout/collection.py b/test/lib/ansible_test/_internal/provider/layout/collection.py
index ffad29f259..6b393b6197 100644
--- a/test/lib/ansible_test/_internal/provider/layout/collection.py
+++ b/test/lib/ansible_test/_internal/provider/layout/collection.py
@@ -16,9 +16,6 @@ from . import (
class CollectionLayout(LayoutProvider):
"""Layout provider for Ansible collections."""
- __module_path = 'plugins/modules'
- __unit_path = 'test/unit'
-
@staticmethod
def is_content_root(path): # type: (str) -> bool
"""Return True if the given path is a content root for this provider."""