mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 15:41:22 -07:00
add jimi-c's unit test for squashed skip results, tweaked is_skipped() logic to pass
This commit is contained in:
parent
85868e07a9
commit
133395db30
2 changed files with 17 additions and 3 deletions
|
@ -40,11 +40,16 @@ class TaskResult:
|
|||
return self._check_key('changed')
|
||||
|
||||
def is_skipped(self):
|
||||
# loop results
|
||||
if 'results' in self._result and self._task.loop:
|
||||
results = self._result['results']
|
||||
return results and all(isinstance(res, dict) and res.get('skipped', False) for res in results)
|
||||
else:
|
||||
return self._result.get('skipped', False)
|
||||
# Loop tasks are only considered skipped if all items were skipped.
|
||||
# some squashed results (eg, yum) are not dicts and can't be skipped individually
|
||||
if results and all(isinstance(res, dict) and res.get('skipped', False) for res in results):
|
||||
return True
|
||||
|
||||
# regular tasks and squashed non-dict results
|
||||
return self._result.get('skipped', False)
|
||||
|
||||
def is_failed(self):
|
||||
if 'failed_when_result' in self._result or \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue