ansible-test - Fix traceback in validate-modules test.

pull/76494/head
Matt Clay 3 years ago
parent 33a8d06332
commit 41ee4a5b12

@ -0,0 +1,2 @@
bugfixes:
- ansible-test - Fix traceback in the ``validate-modules`` sanity test when testing an Ansible module without any callables.

@ -0,0 +1,23 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = '''
module: no_callable
short_description: No callale test module
description: No callable test module.
author:
- Ansible Core Team
'''
EXAMPLES = '''#'''
RETURN = ''''''
from ansible.module_utils.basic import AnsibleModule
if __name__ == '__main__':
module = AnsibleModule(argument_spec=dict())
module.exit_json()

@ -606,7 +606,7 @@ class ModuleValidator(Validator):
if isinstance(child, (ast.FunctionDef, ast.ClassDef)):
linenos.append(child.lineno)
return min(linenos)
return min(linenos) if linenos else None
def _find_has_import(self):
for child in self.ast.body:
@ -2179,7 +2179,7 @@ class ModuleValidator(Validator):
self._find_rejectlist_imports()
self._find_module_utils()
self._find_has_import()
first_callable = self._get_first_callable()
first_callable = self._get_first_callable() or 1000000 # use a bogus "high" line number if no callable exists
self._ensure_imports_below_docs(doc_info, first_callable)
self._check_for_subprocess()
self._check_for_os_call()

Loading…
Cancel
Save