mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Improve code style
This commit is contained in:
parent
8b9f707c21
commit
07738cc848
2 changed files with 6 additions and 6 deletions
|
@ -53,16 +53,16 @@ EXAMPLES = '''
|
||||||
- "'foo' in some_command_result.stdout"
|
- "'foo' in some_command_result.stdout"
|
||||||
- "number_of_the_counting == 3"
|
- "number_of_the_counting == 3"
|
||||||
|
|
||||||
# after version 2.7 both 'msg' and 'fail_msg' can customize failing assertion message
|
- name: after version 2.7 both 'msg' and 'fail_msg' can customize failing assertion message
|
||||||
- assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "my_param <= 100"
|
- "my_param <= 100"
|
||||||
- "my_param >= 0"
|
- "my_param >= 0"
|
||||||
fail_msg: "'my_param' must be between 0 and 100"
|
fail_msg: "'my_param' must be between 0 and 100"
|
||||||
success_msg: "'my_param' is between 0 and 100"
|
success_msg: "'my_param' is between 0 and 100"
|
||||||
|
|
||||||
# please use 'msg' when ansible version is smaller than 2.7
|
- name: please use 'msg' when ansible version is smaller than 2.7
|
||||||
- assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "my_param <= 100"
|
- "my_param <= 100"
|
||||||
- "my_param >= 0"
|
- "my_param >= 0"
|
||||||
|
|
|
@ -44,13 +44,13 @@ class ActionModule(ActionBase):
|
||||||
fail_msg = self._task.args.get('fail_msg', self._task.args.get('msg'))
|
fail_msg = self._task.args.get('fail_msg', self._task.args.get('msg'))
|
||||||
if fail_msg is None:
|
if fail_msg is None:
|
||||||
fail_msg = 'Assertion failed'
|
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))
|
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')
|
success_msg = self._task.args.get('success_msg')
|
||||||
if success_msg is None:
|
if success_msg is None:
|
||||||
success_msg = 'All assertions passed'
|
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))
|
raise AnsibleError('Incorrect type for success_msg, expected string and got %s' % type(success_msg))
|
||||||
|
|
||||||
# make sure the 'that' items are a list
|
# make sure the 'that' items are a list
|
||||||
|
|
Loading…
Reference in a new issue