From 676f1056cb47ef78aeeaf87d220d0667d9589fcc Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Fri, 20 Mar 2020 17:49:33 -0700 Subject: [PATCH] Fix ansible-test import analysis warning. Fix overlooked in https://github.com/ansible/ansible/pull/68372/ (cherry picked from commit 77732ed50db3b8e27d463663f347088334094bed) --- test/lib/ansible_test/_internal/classification/python.py | 5 +++++ 1 file changed, 5 insertions(+) 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))