From 7a8862975e56f071be44d2c21f5ff46fdd6cd576 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 18 May 2015 11:59:53 -0500 Subject: [PATCH] Fix try/except HAS_ logic --- ansible_testing/modules.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ansible_testing/modules.py b/ansible_testing/modules.py index 05527b3455..77d05ae893 100644 --- a/ansible_testing/modules.py +++ b/ansible_testing/modules.py @@ -93,11 +93,12 @@ class ModuleValidator(object): found_has = False if isinstance(child, ast.TryExcept): bodies = child.body - bodies.extend([h.body for h in child.handlers]) + for handler in child.handlers: + bodies.extend(handler.body) for grandchild in bodies: if isinstance(grandchild, ast.Import): found_try_except_import = True - elif isinstance(grandchild, ast.Assign): + if isinstance(grandchild, ast.Assign): for target in grandchild.targets: if target.id.lower().startswith('has_'): found_has = True