diff --git a/test/lib/ansible_test/_internal/classification/python.py b/test/lib/ansible_test/_internal/classification/python.py index 6141bb80fcf..fa83eed132c 100644 --- a/test/lib/ansible_test/_internal/classification/python.py +++ b/test/lib/ansible_test/_internal/classification/python.py @@ -321,6 +321,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))