diff options
Diffstat (limited to 'test/lib/ansible_test/_internal/import_analysis.py')
-rw-r--r-- | test/lib/ansible_test/_internal/import_analysis.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/test/lib/ansible_test/_internal/import_analysis.py b/test/lib/ansible_test/_internal/import_analysis.py index b718e04a60..64b2e993c0 100644 --- a/test/lib/ansible_test/_internal/import_analysis.py +++ b/test/lib/ansible_test/_internal/import_analysis.py @@ -190,7 +190,7 @@ def get_import_path(name, package=False): # type: (str, bool) -> str else: filename = '%s.py' % name.replace('.', '/') - if name.startswith('ansible.module_utils.'): + if name.startswith('ansible.module_utils.') or name == 'ansible.module_utils': path = os.path.join('lib', filename) elif data_context().content.collection and name.startswith('ansible_collections.%s.plugins.module_utils.' % data_context().content.collection.full_name): path = '/'.join(filename.split('/')[3:]) @@ -274,6 +274,11 @@ class ModuleUtilFinder(ast.NodeVisitor): if is_subdir(self.path, data_context().content.test_path): return # invalid imports in tests are ignored + path = get_import_path(name, True) + + if os.path.exists(path) and os.path.getsize(path) == 0: + return # zero length __init__.py files are ignored during earlier processing, do not warn about them now + # Treat this error as a warning so tests can be executed as best as possible. # This error should be detected by unit or integration tests. display.warning('%s:%d Invalid module_utils import: %s' % (self.path, line_number, import_name)) |