1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-24 06:07:19 +00:00

Reformat everything.

This commit is contained in:
Felix Fontein 2025-11-01 12:08:41 +01:00
parent 3f2213791a
commit 340ff8586d
1008 changed files with 61301 additions and 58309 deletions

View file

@ -70,14 +70,14 @@ TC_RUNNER = dict(
bb=dict(fmt_func=cmd_runner_fmt.as_bool, fmt_arg="--bb-here"),
),
runner_init_args=dict(command="testing"),
runner_ctx_args=dict(args_order=['aa', 'bb']),
runner_ctx_args=dict(args_order=["aa", "bb"]),
),
dict(runner_ctx_run_args=dict(bb=True), rc=0, out="", err=""),
dict(
run_info=dict(
cmd=['/mock/bin/python', 'testing', '--answer=11', '--bb-here'],
environ_update={'LANGUAGE': 'C', 'LC_ALL': 'C'},
args_order=('aa', 'bb'),
cmd=["/mock/bin/python", "testing", "--answer=11", "--bb-here"],
environ_update={"LANGUAGE": "C", "LC_ALL": "C"},
args_order=("aa", "bb"),
),
),
),
@ -88,14 +88,14 @@ TC_RUNNER = dict(
bb=dict(fmt_func=cmd_runner_fmt.as_bool, fmt_arg="--bb-here"),
),
runner_init_args=dict(command="toasting", python="python3"),
runner_ctx_args=dict(args_order=['aa', 'bb']),
runner_ctx_args=dict(args_order=["aa", "bb"]),
),
dict(runner_ctx_run_args=dict(bb=True), rc=0, out="", err=""),
dict(
run_info=dict(
cmd=['/mock/bin/python3', 'toasting', '--answer=11', '--bb-here'],
environ_update={'LANGUAGE': 'C', 'LC_ALL': 'C'},
args_order=('aa', 'bb'),
cmd=["/mock/bin/python3", "toasting", "--answer=11", "--bb-here"],
environ_update={"LANGUAGE": "C", "LC_ALL": "C"},
args_order=("aa", "bb"),
),
),
),
@ -106,14 +106,14 @@ TC_RUNNER = dict(
bb=dict(fmt_func=cmd_runner_fmt.as_bool, fmt_arg="--bb-here"),
),
runner_init_args=dict(command="toasting", python="/crazy/local/bin/python3"),
runner_ctx_args=dict(args_order=['aa', 'bb']),
runner_ctx_args=dict(args_order=["aa", "bb"]),
),
dict(runner_ctx_run_args=dict(bb=True), rc=0, out="", err=""),
dict(
run_info=dict(
cmd=['/crazy/local/bin/python3', 'toasting', '--answer=11', '--bb-here'],
environ_update={'LANGUAGE': 'C', 'LC_ALL': 'C'},
args_order=('aa', 'bb'),
cmd=["/crazy/local/bin/python3", "toasting", "--answer=11", "--bb-here"],
environ_update={"LANGUAGE": "C", "LC_ALL": "C"},
args_order=("aa", "bb"),
),
),
),
@ -124,14 +124,14 @@ TC_RUNNER = dict(
bb=dict(fmt_func=cmd_runner_fmt.as_bool, fmt_arg="--bb-here"),
),
runner_init_args=dict(command="toasting", venv="/venv"),
runner_ctx_args=dict(args_order=['aa', 'bb']),
runner_ctx_args=dict(args_order=["aa", "bb"]),
),
dict(runner_ctx_run_args=dict(bb=True), rc=0, out="", err=""),
dict(
run_info=dict(
cmd=['/venv/bin/python', 'toasting', '--answer=11', '--bb-here'],
environ_update={'LANGUAGE': 'C', 'LC_ALL': 'C', 'VIRTUAL_ENV': '/venv', 'PATH': '/venv/bin'},
args_order=('aa', 'bb'),
cmd=["/venv/bin/python", "toasting", "--answer=11", "--bb-here"],
environ_update={"LANGUAGE": "C", "LC_ALL": "C", "VIRTUAL_ENV": "/venv", "PATH": "/venv/bin"},
args_order=("aa", "bb"),
),
),
),
@ -139,28 +139,28 @@ TC_RUNNER = dict(
TC_RUNNER_IDS = sorted(TC_RUNNER.keys())
@pytest.mark.parametrize('runner_input, cmd_execution, expected',
(TC_RUNNER[tc] for tc in TC_RUNNER_IDS),
ids=TC_RUNNER_IDS)
@pytest.mark.parametrize(
"runner_input, cmd_execution, expected", (TC_RUNNER[tc] for tc in TC_RUNNER_IDS), ids=TC_RUNNER_IDS
)
def test_runner_context(runner_input, cmd_execution, expected):
arg_spec = {}
params = {}
arg_formats = {}
for k, v in runner_input['args_bundle'].items():
for k, v in runner_input["args_bundle"].items():
try:
arg_spec[k] = {'type': v['type']}
arg_spec[k] = {"type": v["type"]}
except KeyError:
pass
try:
params[k] = v['value']
params[k] = v["value"]
except KeyError:
pass
try:
arg_formats[k] = v['fmt_func'](v['fmt_arg'])
arg_formats[k] = v["fmt_func"](v["fmt_arg"])
except KeyError:
pass
orig_results = tuple(cmd_execution[x] for x in ('rc', 'out', 'err'))
orig_results = tuple(cmd_execution[x] for x in ("rc", "out", "err"))
print(f"arg_spec={arg_spec}\nparams={params}\narg_formats={arg_formats}\n")
@ -170,24 +170,16 @@ def test_runner_context(runner_input, cmd_execution, expected):
module.get_bin_path.return_value = os.path.join(
runner_input["runner_init_args"].get("venv", "/mock"),
"bin",
runner_input["runner_init_args"].get("python", "python")
runner_input["runner_init_args"].get("python", "python"),
)
module.run_command.return_value = orig_results
runner = PythonRunner(
module=module,
arg_formats=arg_formats,
**runner_input['runner_init_args']
)
runner = PythonRunner(module=module, arg_formats=arg_formats, **runner_input["runner_init_args"])
def _extract_path(run_info):
path = run_info.get("environ_update", {}).get("PATH")
if path is not None:
run_info["environ_update"] = {
k: v
for k, v in run_info["environ_update"].items()
if k != "PATH"
}
run_info["environ_update"] = {k: v for k, v in run_info["environ_update"].items() if k != "PATH"}
return run_info, path
def _assert_run_info_env_path(actual, expected):
@ -203,17 +195,17 @@ def test_runner_context(runner_input, cmd_execution, expected):
assert reduced == expected, f"{reduced}"
def _assert_run(expected, ctx, results):
_assert_run_info(ctx.run_info, expected['run_info'])
assert results == expected.get('results', orig_results)
_assert_run_info(ctx.run_info, expected["run_info"])
assert results == expected.get("results", orig_results)
exc = expected.get("exc")
if exc:
with pytest.raises(exc):
with runner.context(**runner_input['runner_ctx_args']) as ctx:
results = ctx.run(**cmd_execution['runner_ctx_run_args'])
with runner.context(**runner_input["runner_ctx_args"]) as ctx:
results = ctx.run(**cmd_execution["runner_ctx_run_args"])
_assert_run(expected, ctx, results)
else:
with runner.context(**runner_input['runner_ctx_args']) as ctx:
results = ctx.run(**cmd_execution['runner_ctx_run_args'])
with runner.context(**runner_input["runner_ctx_args"]) as ctx:
results = ctx.run(**cmd_execution["runner_ctx_run_args"])
_assert_run(expected, ctx, results)