mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Run pyupgrade
against the changes from the merge-forward
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
819c2dc9e7
commit
2e962677b7
8 changed files with 62 additions and 75 deletions
|
@ -369,21 +369,21 @@ def test_issue_30161_unless_and_onlyif_together(state, state_tree, tmp_path):
|
|||
# then the unless state run bailed out after the first unless command succeeded,
|
||||
# which is the bug we're regression testing for.
|
||||
_expected = {
|
||||
"file_|-unless_false_onlyif_false_|-{}_|-managed".format(test_txt_path): {
|
||||
f"file_|-unless_false_onlyif_false_|-{test_txt_path}_|-managed": {
|
||||
"comment": "onlyif condition is false\nunless condition is false",
|
||||
"name": "{}".format(test_txt_path),
|
||||
"name": f"{test_txt_path}",
|
||||
"skip_watch": True,
|
||||
"changes": {},
|
||||
"result": True,
|
||||
},
|
||||
"file_|-unless_false_onlyif_true_|-{}_|-managed".format(test_txt_path): {
|
||||
f"file_|-unless_false_onlyif_true_|-{test_txt_path}_|-managed": {
|
||||
"comment": "Empty file",
|
||||
"name": str(test_txt_path),
|
||||
"start_time": "18:10:20.341753",
|
||||
"result": True,
|
||||
"changes": {"new": "file {} created".format(test_txt_path)},
|
||||
"changes": {"new": f"file {test_txt_path} created"},
|
||||
},
|
||||
"file_|-unless_true_onlyif_false_|-{}_|-managed".format(test_txt_path): {
|
||||
f"file_|-unless_true_onlyif_false_|-{test_txt_path}_|-managed": {
|
||||
"comment": "onlyif condition is false\nunless condition is true",
|
||||
"name": str(test_txt_path),
|
||||
"start_time": "18:10:22.936446",
|
||||
|
@ -391,7 +391,7 @@ def test_issue_30161_unless_and_onlyif_together(state, state_tree, tmp_path):
|
|||
"changes": {},
|
||||
"result": True,
|
||||
},
|
||||
"file_|-unless_true_onlyif_true_|-{}_|-managed".format(test_txt_path): {
|
||||
f"file_|-unless_true_onlyif_true_|-{test_txt_path}_|-managed": {
|
||||
"comment": "onlyif condition is true\nunless condition is true",
|
||||
"name": str(test_txt_path),
|
||||
"skip_watch": True,
|
||||
|
|
|
@ -609,7 +609,7 @@ def test_parallel_state_with_requires(state, state_tree):
|
|||
assert (end_time - start_time) < 30
|
||||
|
||||
for item in range(1, 10):
|
||||
_id = "cmd_|-blah-{}_|-sleep 2_|-run".format(item)
|
||||
_id = f"cmd_|-blah-{item}_|-sleep 2_|-run"
|
||||
assert "__parallel__" in ret[_id]
|
||||
|
||||
|
||||
|
|
|
@ -113,51 +113,51 @@ def test_requisites_watch_any(state, state_tree):
|
|||
cmd_true=cmd_true, cmd_false=cmd_false
|
||||
)
|
||||
expected_result = {
|
||||
"cmd_|-A_|-{}_|-wait".format(cmd_true): {
|
||||
f"cmd_|-A_|-{cmd_true}_|-wait": {
|
||||
"__run_num__": 4,
|
||||
"comment": 'Command "{}" run'.format(cmd_true),
|
||||
"comment": f'Command "{cmd_true}" run',
|
||||
"result": True,
|
||||
"changes": True,
|
||||
},
|
||||
"cmd_|-B_|-{}_|-run".format(cmd_true): {
|
||||
f"cmd_|-B_|-{cmd_true}_|-run": {
|
||||
"__run_num__": 0,
|
||||
"comment": 'Command "{}" run'.format(cmd_true),
|
||||
"comment": f'Command "{cmd_true}" run',
|
||||
"result": True,
|
||||
"changes": True,
|
||||
},
|
||||
"cmd_|-C_|-{}_|-run".format(cmd_false): {
|
||||
f"cmd_|-C_|-{cmd_false}_|-run": {
|
||||
"__run_num__": 1,
|
||||
"comment": 'Command "{}" run'.format(cmd_false),
|
||||
"comment": f'Command "{cmd_false}" run',
|
||||
"result": False,
|
||||
"changes": True,
|
||||
},
|
||||
"cmd_|-D_|-{}_|-run".format(cmd_true): {
|
||||
f"cmd_|-D_|-{cmd_true}_|-run": {
|
||||
"__run_num__": 2,
|
||||
"comment": 'Command "{}" run'.format(cmd_true),
|
||||
"comment": f'Command "{cmd_true}" run',
|
||||
"result": True,
|
||||
"changes": True,
|
||||
},
|
||||
"cmd_|-E_|-{}_|-wait".format(cmd_true): {
|
||||
f"cmd_|-E_|-{cmd_true}_|-wait": {
|
||||
"__run_num__": 9,
|
||||
"comment": 'Command "{}" run'.format(cmd_true),
|
||||
"comment": f'Command "{cmd_true}" run',
|
||||
"result": True,
|
||||
"changes": True,
|
||||
},
|
||||
"cmd_|-F_|-{}_|-run".format(cmd_true): {
|
||||
f"cmd_|-F_|-{cmd_true}_|-run": {
|
||||
"__run_num__": 5,
|
||||
"comment": 'Command "{}" run'.format(cmd_true),
|
||||
"comment": f'Command "{cmd_true}" run',
|
||||
"result": True,
|
||||
"changes": True,
|
||||
},
|
||||
"cmd_|-G_|-{}_|-run".format(cmd_false): {
|
||||
f"cmd_|-G_|-{cmd_false}_|-run": {
|
||||
"__run_num__": 6,
|
||||
"comment": 'Command "{}" run'.format(cmd_false),
|
||||
"comment": f'Command "{cmd_false}" run',
|
||||
"result": False,
|
||||
"changes": True,
|
||||
},
|
||||
"cmd_|-H_|-{}_|-run".format(cmd_false): {
|
||||
f"cmd_|-H_|-{cmd_false}_|-run": {
|
||||
"__run_num__": 7,
|
||||
"comment": 'Command "{}" run'.format(cmd_false),
|
||||
"comment": f'Command "{cmd_false}" run',
|
||||
"result": False,
|
||||
"changes": True,
|
||||
},
|
||||
|
|
|
@ -904,10 +904,8 @@ def test_parallel_state_with_long_tag(state, state_tree):
|
|||
)
|
||||
|
||||
comments = sorted(x.comment for x in ret)
|
||||
expected = sorted(
|
||||
'Command "{}" run'.format(x) for x in (short_command, long_command)
|
||||
)
|
||||
assert comments == expected, "{} != {}".format(comments, expected)
|
||||
expected = sorted(f'Command "{x}" run' for x in (short_command, long_command))
|
||||
assert comments == expected, f"{comments} != {expected}"
|
||||
|
||||
|
||||
@pytest.mark.skip_on_darwin(reason="Test is broken on macosx")
|
||||
|
|
|
@ -155,7 +155,7 @@ def test_interrupt_on_long_running_job(salt_cli, salt_master, salt_minion):
|
|||
cmdline = [
|
||||
sys.executable,
|
||||
salt_cli.get_script_path(),
|
||||
"--config-dir={}".format(salt_master.config_dir),
|
||||
f"--config-dir={salt_master.config_dir}",
|
||||
salt_minion.id,
|
||||
"test.sleep",
|
||||
"30",
|
||||
|
|
|
@ -44,9 +44,7 @@ def clear_proxy_minions(salt_master, proxy_minion_id):
|
|||
for proxy in [proxy_minion_id, "dummy_proxy_one", "dummy_proxy_two"]:
|
||||
pytest.helpers.remove_stale_minion_key(salt_master, proxy)
|
||||
|
||||
cachefile = os.path.join(
|
||||
salt_master.config["cachedir"], "{}.cache".format(proxy)
|
||||
)
|
||||
cachefile = os.path.join(salt_master.config["cachedir"], f"{proxy}.cache")
|
||||
if os.path.exists(cachefile):
|
||||
os.unlink(cachefile)
|
||||
|
||||
|
@ -181,11 +179,11 @@ def test_exit_status_correct_usage(
|
|||
"controlproxy.sls", controlproxy_pillar_file
|
||||
)
|
||||
dummy_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
|
||||
"{}.sls".format(proxy_one),
|
||||
f"{proxy_one}.sls",
|
||||
dummy_proxy_one_pillar_file,
|
||||
)
|
||||
dummy_proxy_two_tempfile = salt_master.pillar_tree.base.temp_file(
|
||||
"{}.sls".format(proxy_two),
|
||||
f"{proxy_two}.sls",
|
||||
dummy_proxy_two_pillar_file,
|
||||
)
|
||||
with top_tempfile, controlproxy_tempfile, dummy_proxy_one_tempfile, dummy_proxy_two_tempfile:
|
||||
|
@ -288,7 +286,7 @@ def test_missing_pillar_file(
|
|||
"controlproxy.sls", controlproxy_pillar_file
|
||||
)
|
||||
dummy_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
|
||||
"{}.sls".format(proxy_one),
|
||||
f"{proxy_one}.sls",
|
||||
dummy_proxy_one_pillar_file,
|
||||
)
|
||||
with top_tempfile, controlproxy_tempfile, dummy_proxy_one_tempfile:
|
||||
|
@ -406,14 +404,14 @@ def test_invalid_connection(
|
|||
"controlproxy.sls", controlproxy_pillar_file
|
||||
)
|
||||
dummy_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
|
||||
"{}.sls".format(proxy_one),
|
||||
f"{proxy_one}.sls",
|
||||
dummy_proxy_one_pillar_file,
|
||||
)
|
||||
broken_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
|
||||
"{}.sls".format(broken_proxy_one), broken_proxy_one_pillar_file
|
||||
f"{broken_proxy_one}.sls", broken_proxy_one_pillar_file
|
||||
)
|
||||
broken_proxy_two_tempfile = salt_master.pillar_tree.base.temp_file(
|
||||
"{}.sls".format(broken_proxy_two), broken_proxy_two_pillar_file
|
||||
f"{broken_proxy_two}.sls", broken_proxy_two_pillar_file
|
||||
)
|
||||
with top_tempfile, controlproxy_tempfile, dummy_proxy_one_tempfile, broken_proxy_one_tempfile, broken_proxy_two_tempfile:
|
||||
factory = salt_master.salt_proxy_minion_daemon(
|
||||
|
@ -534,11 +532,11 @@ def ping():
|
|||
"controlproxy.sls", controlproxy_pillar_file
|
||||
)
|
||||
dummy_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
|
||||
"{}.sls".format(proxy_one),
|
||||
f"{proxy_one}.sls",
|
||||
dummy_proxy_one_pillar_file,
|
||||
)
|
||||
dummy_proxy_two_tempfile = salt_master.pillar_tree.base.temp_file(
|
||||
"{}.sls".format(proxy_two),
|
||||
f"{proxy_two}.sls",
|
||||
dummy_proxy_two_pillar_file,
|
||||
)
|
||||
|
||||
|
@ -668,11 +666,11 @@ def ping():
|
|||
"controlproxy.sls", controlproxy_pillar_file
|
||||
)
|
||||
dummy_proxy_one_tempfile = salt_master.pillar_tree.base.temp_file(
|
||||
"{}.sls".format(proxy_one),
|
||||
f"{proxy_one}.sls",
|
||||
dummy_proxy_one_pillar_file,
|
||||
)
|
||||
dummy_proxy_two_tempfile = salt_master.pillar_tree.base.temp_file(
|
||||
"{}.sls".format(proxy_two),
|
||||
f"{proxy_two}.sls",
|
||||
dummy_proxy_two_pillar_file,
|
||||
)
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ def test_contents_pillar_with_pillar_list(salt_master, salt_call_cli, tmp_path):
|
|||
target_path
|
||||
)
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
f"{sls_name}.sls", sls_contents
|
||||
)
|
||||
with sls_tempfile:
|
||||
ret = salt_call_cli.run("state.sls", sls_name)
|
||||
|
@ -315,7 +315,7 @@ def test_managed_file_with_pillar_sls(salt_master, salt_call_cli, tmp_path):
|
|||
assert ret.returncode == 0
|
||||
assert ret.data
|
||||
|
||||
target_path = tmp_path / "file-pillar-{}-target.txt".format(ret.data)
|
||||
target_path = tmp_path / f"file-pillar-{ret.data}-target.txt"
|
||||
sls_name = "file-pillar-get"
|
||||
sls_contents = (
|
||||
"""
|
||||
|
@ -329,7 +329,7 @@ def test_managed_file_with_pillar_sls(salt_master, salt_call_cli, tmp_path):
|
|||
"""
|
||||
)
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
f"{sls_name}.sls", sls_contents
|
||||
)
|
||||
with sls_tempfile:
|
||||
ret = salt_call_cli.run("state.sls", sls_name)
|
||||
|
@ -358,7 +358,7 @@ def test_issue_50221(
|
|||
- contents_pillar: issue-50221
|
||||
"""
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
f"{sls_name}.sls", sls_contents
|
||||
)
|
||||
issue_50221_ext_pillar_tempfile = pytest.helpers.temp_file(
|
||||
"issue-50221",
|
||||
|
@ -421,11 +421,11 @@ def test_issue_60426(
|
|||
)
|
||||
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
f"{sls_name}.sls", sls_contents
|
||||
)
|
||||
|
||||
jinja_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.jinja".format(jinja_name), jinja_contents
|
||||
f"{jinja_name}.jinja", jinja_contents
|
||||
)
|
||||
|
||||
with sls_tempfile, jinja_tempfile:
|
||||
|
@ -462,11 +462,11 @@ def test_issue_60426(
|
|||
)
|
||||
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
f"{sls_name}.sls", sls_contents
|
||||
)
|
||||
|
||||
jinja_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.jinja".format(jinja_name), jinja_contents
|
||||
f"{jinja_name}.jinja", jinja_contents
|
||||
)
|
||||
|
||||
with sls_tempfile, jinja_tempfile:
|
||||
|
@ -700,9 +700,10 @@ def test_patch_saltenv(salt_call_cli, content, math_patch_file, salt_master, tmp
|
|||
# Check to make sure the patch was applied okay
|
||||
state_run = next(iter(ret.data.values()))
|
||||
assert state_run["result"] is False
|
||||
assert state_run[
|
||||
"comment"
|
||||
] == "Source file {} not found in saltenv 'prod'".format(math_patch_file)
|
||||
assert (
|
||||
state_run["comment"]
|
||||
== f"Source file {math_patch_file} not found in saltenv 'prod'"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skip_unless_on_windows
|
||||
|
@ -774,9 +775,7 @@ def test_patch_single_file_failure(
|
|||
state_run = next(iter(ret.data.values()))
|
||||
assert "Patch would not apply cleanly" in state_run["comment"]
|
||||
assert (
|
||||
re.match(
|
||||
state_run["comment"], "saving rejects to (file )?{}".format(reject_file)
|
||||
)
|
||||
re.match(state_run["comment"], f"saving rejects to (file )?{reject_file}")
|
||||
is None
|
||||
)
|
||||
|
||||
|
@ -849,9 +848,7 @@ def test_patch_directory_failure(
|
|||
state_run = next(iter(ret.data.values()))
|
||||
assert "Patch would not apply cleanly" in state_run["comment"]
|
||||
assert (
|
||||
re.match(
|
||||
state_run["comment"], "saving rejects to (file )?{}".format(reject_file)
|
||||
)
|
||||
re.match(state_run["comment"], f"saving rejects to (file )?{reject_file}")
|
||||
is None
|
||||
)
|
||||
|
||||
|
@ -1067,7 +1064,7 @@ def test_recurse(
|
|||
test_tempdir = salt_master.state_tree.base.write_path / "tmp_dir"
|
||||
test_tempdir.mkdir(parents=True, exist_ok=True)
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
f"{sls_name}.sls", sls_contents
|
||||
)
|
||||
|
||||
with sls_tempfile:
|
||||
|
@ -1114,7 +1111,7 @@ def test_recurse_keep_symlinks_in_fileserver_root(
|
|||
test_tempdir = salt_master.state_tree.base.write_path / "tmp_dir"
|
||||
test_tempdir.mkdir(parents=True, exist_ok=True)
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
f"{sls_name}.sls", sls_contents
|
||||
)
|
||||
|
||||
with sls_tempfile:
|
||||
|
@ -1166,7 +1163,7 @@ def test_recurse_keep_symlinks_outside_fileserver_root(
|
|||
test_tempdir = salt_secondary_master.state_tree.base.write_path / "tmp_dir"
|
||||
test_tempdir.mkdir(parents=True, exist_ok=True)
|
||||
sls_tempfile = salt_secondary_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
f"{sls_name}.sls", sls_contents
|
||||
)
|
||||
|
||||
with sls_tempfile:
|
||||
|
@ -1218,17 +1215,13 @@ def test_issue_62117(
|
|||
- name: pwd
|
||||
"""
|
||||
|
||||
yaml_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.yaml".format(name), yaml_contents
|
||||
)
|
||||
yaml_tempfile = salt_master.state_tree.base.temp_file(f"{name}.yaml", yaml_contents)
|
||||
|
||||
jinja_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.jinja".format(name), jinja_contents
|
||||
f"{name}.jinja", jinja_contents
|
||||
)
|
||||
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(name), sls_contents
|
||||
)
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(f"{name}.sls", sls_contents)
|
||||
|
||||
with yaml_tempfile, jinja_tempfile, sls_tempfile:
|
||||
ret = salt_call_cli.run("--local", "state.apply", name.replace("/", "."))
|
||||
|
@ -1264,12 +1257,10 @@ def test_issue_62611(
|
|||
)
|
||||
|
||||
jinja_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.jinja".format(name), jinja_contents
|
||||
f"{name}.jinja", jinja_contents
|
||||
)
|
||||
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(name), sls_contents
|
||||
)
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(f"{name}.sls", sls_contents)
|
||||
|
||||
with jinja_tempfile, sls_tempfile:
|
||||
ret = salt_call_cli.run("--local", "state.apply", name.replace("/", "."))
|
||||
|
@ -1296,7 +1287,7 @@ def test_contents_file(salt_master, salt_call_cli, tmp_path):
|
|||
target_path
|
||||
)
|
||||
sls_tempfile = salt_master.state_tree.base.temp_file(
|
||||
"{}.sls".format(sls_name), sls_contents
|
||||
f"{sls_name}.sls", sls_contents
|
||||
)
|
||||
with sls_tempfile:
|
||||
for i in range(1, 4):
|
||||
|
|
|
@ -530,7 +530,7 @@ def test_verify_onlyif_parse_slots(tmp_path, minion_opts):
|
|||
"onlyif": [
|
||||
{
|
||||
"fun": "file.search",
|
||||
"args": ["__slot__:salt:test.echo({})".format(_expand_win_path(name))],
|
||||
"args": [f"__slot__:salt:test.echo({_expand_win_path(name)})"],
|
||||
"pattern": "__slot__:salt:test.echo(file-contents)",
|
||||
}
|
||||
],
|
||||
|
@ -632,7 +632,7 @@ def test_verify_unless_parse_slots(tmp_path, minion_opts):
|
|||
"unless": [
|
||||
{
|
||||
"fun": "file.search",
|
||||
"args": ["__slot__:salt:test.echo({})".format(_expand_win_path(name))],
|
||||
"args": [f"__slot__:salt:test.echo({_expand_win_path(name)})"],
|
||||
"pattern": "__slot__:salt:test.echo(file-contents)",
|
||||
}
|
||||
],
|
||||
|
|
Loading…
Add table
Reference in a new issue