Improve code style

This commit is contained in:
HD650 2018-06-18 15:01:38 -04:00 committed by Zhikang Zhang
parent 8b9f707c21
commit 07738cc848
2 changed files with 6 additions and 6 deletions

View file

@ -53,16 +53,16 @@ EXAMPLES = '''
- "'foo' in some_command_result.stdout"
- "number_of_the_counting == 3"
# after version 2.7 both 'msg' and 'fail_msg' can customize failing assertion message
- assert:
- name: after version 2.7 both 'msg' and 'fail_msg' can customize failing assertion message
assert:
that:
- "my_param <= 100"
- "my_param >= 0"
fail_msg: "'my_param' must be between 0 and 100"
success_msg: "'my_param' is between 0 and 100"
# please use 'msg' when ansible version is smaller than 2.7
- assert:
- name: please use 'msg' when ansible version is smaller than 2.7
assert:
that:
- "my_param <= 100"
- "my_param >= 0"

View file

@ -44,13 +44,13 @@ class ActionModule(ActionBase):
fail_msg = self._task.args.get('fail_msg', self._task.args.get('msg'))
if fail_msg is None:
fail_msg = 'Assertion failed'
if not isinstance(fail_msg, string_types):
elif not isinstance(fail_msg, string_types):
raise AnsibleError('Incorrect type for fail_msg or msg, expected string and got %s' % type(fail_msg))
success_msg = self._task.args.get('success_msg')
if success_msg is None:
success_msg = 'All assertions passed'
if not isinstance(success_msg, string_types):
elif not isinstance(success_msg, string_types):
raise AnsibleError('Incorrect type for success_msg, expected string and got %s' % type(success_msg))
# make sure the 'that' items are a list