summaryrefslogtreecommitdiffstats
path: root/test/runner/lib/classification.py
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2017-03-23 02:07:53 +0100
committerGitHub <noreply@github.com>2017-03-23 02:07:53 +0100
commit4fdeade3897a5808ccdb6eb002c4a8ebbe794811 (patch)
tree97d697c2e8f509fd4225ad6da150034190df0bd7 /test/runner/lib/classification.py
parentImport camel_dict_to_snake_dict method to fix error when executing get_nat_ga... (diff)
downloadansible-4fdeade3897a5808ccdb6eb002c4a8ebbe794811.tar.xz
ansible-4fdeade3897a5808ccdb6eb002c4a8ebbe794811.zip
Overhaul ansible-test import analysis. (#22888)
- Add support for module_utils packages for better organization. - Add support for "virtual" module_utils packages such as `six`.
Diffstat (limited to 'test/runner/lib/classification.py')
-rw-r--r--test/runner/lib/classification.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/test/runner/lib/classification.py b/test/runner/lib/classification.py
index 63ca804eab..b576cfacb8 100644
--- a/test/runner/lib/classification.py
+++ b/test/runner/lib/classification.py
@@ -130,19 +130,22 @@ class PathMapper(object):
:type path: str
:rtype: list[str]
"""
- name, ext = os.path.splitext(os.path.split(path)[1])
+ ext = os.path.splitext(os.path.split(path)[1])[1]
if path.startswith('lib/ansible/module_utils/'):
if ext == '.py':
- return self.get_python_module_utils_usage(name)
+ return self.get_python_module_utils_usage(path)
return []
- def get_python_module_utils_usage(self, name):
+ def get_python_module_utils_usage(self, path):
"""
- :type name: str
+ :type path: str
:rtype: list[str]
"""
+ if path == 'lib/ansible/module_utils/__init__.py':
+ return []
+
if not self.python_module_utils_imports:
display.info('Analyzing python module_utils imports...')
before = time.time()
@@ -150,7 +153,12 @@ class PathMapper(object):
after = time.time()
display.info('Processed %d python module_utils in %d second(s).' % (len(self.python_module_utils_imports), after - before))
- return sorted(self.python_module_utils_imports.get(name, set()))
+ name = os.path.splitext(path)[0].replace('/', '.')[4:]
+
+ if name.endswith('.__init__'):
+ name = name[:-9]
+
+ return sorted(self.python_module_utils_imports[name])
def classify(self, path):
"""