summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2020-03-20 09:20:46 -0700
committerMatt Clay <matt@mystile.com>2020-03-20 17:18:03 -0700
commitab276803183a08bb62626ff1ddd711221888e708 (patch)
treec4528991e9e3964da4e9e9985ebd62bd663dbfb7
parent649fad2d83702580a88a73b52d34be75381c64b7 (diff)
downloadansible-ab276803183a08bb62626ff1ddd711221888e708.tar.gz
Fix ansible-test module_utils import analysis.
Now empty `*.py` files are ignored during module_utils import analysis for change detection. This eliminates "No imports found" warnings for files which should have no imports.
-rw-r--r--changelogs/fragments/ansible-test-change-detection-fix.yml2
-rw-r--r--test/lib/ansible_test/_internal/import_analysis.py4
2 files changed, 4 insertions, 2 deletions
diff --git a/changelogs/fragments/ansible-test-change-detection-fix.yml b/changelogs/fragments/ansible-test-change-detection-fix.yml
new file mode 100644
index 0000000000..3917afec3d
--- /dev/null
+++ b/changelogs/fragments/ansible-test-change-detection-fix.yml
@@ -0,0 +1,2 @@
+bugfixes:
+ - ansible-test now ignores empty ``*.py`` files when analyzing module_utils imports for change detection
diff --git a/test/lib/ansible_test/_internal/import_analysis.py b/test/lib/ansible_test/_internal/import_analysis.py
index d115cffa7f..b718e04a60 100644
--- a/test/lib/ansible_test/_internal/import_analysis.py
+++ b/test/lib/ansible_test/_internal/import_analysis.py
@@ -148,10 +148,10 @@ def enumerate_module_utils():
for path in data_context().content.walk_files(data_context().content.module_utils_path):
ext = os.path.splitext(path)[1]
- if path == os.path.join(data_context().content.module_utils_path, '__init__.py'):
+ if ext != '.py':
continue
- if ext != '.py':
+ if os.path.getsize(path) == 0:
continue
module_utils.append(get_python_module_utils_name(path))