mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -07:00
[PR #8415/7d72300c backport][stable-9] add cmd_runner_fmt.stack decorator (#8448)
add cmd_runner_fmt.stack decorator (#8415)
* add cmd_runner_fmt.stack decorator
* fix sanity
* fix typo
* add changelog frag
(cherry picked from commit 7d72300c36
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
1795a67b8e
commit
212871fcaf
3 changed files with 30 additions and 2 deletions
|
@ -47,6 +47,9 @@ TC_FORMATS = dict(
|
|||
simple_fixed_false=(partial(cmd_runner_fmt.as_fixed, ["--always-here", "--forever"]), False, ["--always-here", "--forever"], None),
|
||||
simple_fixed_none=(partial(cmd_runner_fmt.as_fixed, ["--always-here", "--forever"]), None, ["--always-here", "--forever"], None),
|
||||
simple_fixed_str=(partial(cmd_runner_fmt.as_fixed, ["--always-here", "--forever"]), "something", ["--always-here", "--forever"], None),
|
||||
stack_optval__str=(partial(cmd_runner_fmt.stack(cmd_runner_fmt.as_optval), "-t"), ["potatoes", "bananas"], ["-tpotatoes", "-tbananas"], None),
|
||||
stack_opt_val__str=(partial(cmd_runner_fmt.stack(cmd_runner_fmt.as_opt_val), "-t"), ["potatoes", "bananas"], ["-t", "potatoes", "-t", "bananas"], None),
|
||||
stack_opt_eq_val__int=(partial(cmd_runner_fmt.stack(cmd_runner_fmt.as_opt_eq_val), "--answer"), [42, 17], ["--answer=42", "--answer=17"], None),
|
||||
)
|
||||
if tuple(version_info) >= (3, 1):
|
||||
from collections import OrderedDict
|
||||
|
@ -67,7 +70,7 @@ TC_FORMATS_IDS = sorted(TC_FORMATS.keys())
|
|||
def test_arg_format(func, value, expected, exception):
|
||||
fmt_func = func()
|
||||
try:
|
||||
actual = fmt_func(value, ctx_ignore_none=True)
|
||||
actual = fmt_func(value)
|
||||
print("formatted string = {0}".format(actual))
|
||||
assert actual == expected, "actual = {0}".format(actual)
|
||||
except Exception as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue