mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 04:11:25 -07:00
Fix UnboundLocalError in basic.py
* Fix for UnboundLocalError while accessing deprecations in result * Add Unit test Fixes #24592 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
9f3a405706
commit
764b4b20ec
2 changed files with 19 additions and 1 deletions
|
@ -69,3 +69,21 @@ class TestAnsibleModuleWarnDeprecate(unittest.TestCase):
|
|||
{u'msg': u'deprecation4', u'version': '2.4'},
|
||||
])
|
||||
|
||||
def test_deprecate_without_list(self):
|
||||
args = json.dumps(dict(ANSIBLE_MODULE_ARGS={}))
|
||||
with swap_stdin_and_argv(stdin_data=args):
|
||||
with swap_stdout():
|
||||
|
||||
ansible.module_utils.basic._ANSIBLE_ARGS = None
|
||||
am = ansible.module_utils.basic.AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
)
|
||||
am._name = 'unittest'
|
||||
|
||||
with self.assertRaises(SystemExit):
|
||||
am.exit_json(deprecations='Simple deprecation warning')
|
||||
output = json.loads(sys.stdout.getvalue())
|
||||
self.assertTrue('warnings' not in output or output['warnings'] == [])
|
||||
self.assertEquals(output['deprecations'], [
|
||||
{u'msg': u'Simple deprecation warning', u'version': None},
|
||||
])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue