Use pop in cb clean results (#33779)

* Fix _clean_result for debug callback with 1 char var names

The check in _clean_results was removing any keys that happened
to be one of the chars in ('invocation') instead of the string
'invocation'. This was meant to be a tuple but there was no comma
so the for iterated the string instead of the tuple.

Introduced in 9dba580204fcc7d95d4ca2ea2ae4ce23fe28c2ed

Update unit test to catch this.

Fixes #33723

* Use .pop() to remove invocation from results dict

In base callback _clean_results, simplify the way the
'invocation' item is removed.

Add some more unit tests.
This commit is contained in:
Adrian Likins 2017-12-11 17:41:12 -05:00 committed by Brian Coca
parent 07e9df11b3
commit a57d6a4206
2 changed files with 42 additions and 6 deletions

View file

@ -236,9 +236,7 @@ class CallbackBase(AnsiblePlugin):
def _clean_results(self, result, task_name):
''' removes data from results for display '''
if task_name in ['debug']:
for remove_key in ('invocation'):
if remove_key in result:
del result[remove_key]
result.pop('invocation', None)
def set_play_context(self, play_context):
pass