diff options
author | Matt Clay <matt@mystile.com> | 2020-03-20 17:49:33 -0700 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2020-03-20 21:04:10 -0700 |
commit | 77732ed50db3b8e27d463663f347088334094bed (patch) | |
tree | 4b82dff7c4350799b6d2aa32d6f3441b4abb9d0f | |
parent | ab276803183a08bb62626ff1ddd711221888e708 (diff) | |
download | ansible-77732ed50db3b8e27d463663f347088334094bed.tar.gz |
Fix ansible-test import analysis warning.
Fix overlooked in https://github.com/ansible/ansible/pull/68372/
-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)) |