From 31475e74e867dffbc581556d56d56aa0009ead1a Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 28 Jun 2023 11:56:47 +0100 Subject: [PATCH] Run `pypugrade` against the files changed in the merge-forward Signed-off-by: Pedro Algarvio --- pkg/tests/integration/test_multi_minion.py | 30 ++++++++----------- salt/runner.py | 8 ++--- .../pytests/functional/cli/test_salt_run_.py | 2 +- tests/pytests/functional/states/test_user.py | 4 +-- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/pkg/tests/integration/test_multi_minion.py b/pkg/tests/integration/test_multi_minion.py index 13d64f31f6e..ba69ab2b5ea 100644 --- a/pkg/tests/integration/test_multi_minion.py +++ b/pkg/tests/integration/test_multi_minion.py @@ -20,10 +20,9 @@ def mm_conf(mm_script): yield pathlib.Path(os.getenv("LocalAppData"), "Salt Project", "Salt", "conf") subprocess.run( ["powershell", str(mm_script).replace(" ", "' '"), "-d"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, check=False, - universal_newlines=True, + text=True, ) @@ -41,10 +40,9 @@ def test_install(mm_script, mm_conf): """ ret = subprocess.run( ["powershell", str(mm_script).replace(" ", "' '")], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, check=False, - universal_newlines=True, + text=True, ) assert ret.returncode == 0, ret.stderr conf_file = mm_conf / "minion" @@ -58,10 +56,9 @@ def test_install_master(mm_script, mm_conf): """ ret = subprocess.run( ["powershell", str(mm_script).replace(" ", "' '"), "-m", "spongebob"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, check=False, - universal_newlines=True, + text=True, ) assert ret.returncode == 0, ret.stderr conf_file = mm_conf / "minion" @@ -75,10 +72,9 @@ def test_install_prefix(mm_script, mm_conf): """ ret = subprocess.run( ["powershell", str(mm_script).replace(" ", "' '"), "-p", "squarepants"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, check=False, - universal_newlines=True, + text=True, ) assert ret.returncode == 0, ret.stderr conf_file = mm_conf / "minion" @@ -92,10 +88,9 @@ def test_install_log_level(mm_script, mm_conf): """ ret = subprocess.run( ["powershell", str(mm_script).replace(" ", "' '"), "-l", "debug"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, check=False, - universal_newlines=True, + text=True, ) assert ret.returncode == 0, ret.stderr conf_file = mm_conf / "minion" @@ -109,10 +104,9 @@ def test_install_start(mm_script, mm_conf): """ ret = subprocess.run( ["powershell", str(mm_script).replace(" ", "' '"), "-s"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, + capture_output=True, check=False, - universal_newlines=True, + text=True, ) assert ret.returncode == 0, ret.stderr conf_file = mm_conf / "minion" diff --git a/salt/runner.py b/salt/runner.py index 2a19636b8ed..d3501b8f919 100644 --- a/salt/runner.py +++ b/salt/runner.py @@ -203,7 +203,7 @@ class Runner(RunnerClient): arg = self.opts.get("fun", None) docs = super().get_docs(arg) for fun in sorted(docs): - display_output("{}:".format(fun), "text", self.opts) + display_output(f"{fun}:", "text", self.opts) print(docs[fun]) # TODO: move to mixin whenever we want a salt-wheel cli @@ -313,13 +313,13 @@ class Runner(RunnerClient): evt.fire_event( { "success": False, - "return": "{}".format(exc), + "return": f"{exc}", "retcode": 254, "fun": self.opts["fun"], "fun_args": fun_args, "jid": self.jid, }, - tag="salt/run/{}/ret".format(self.jid), + tag=f"salt/run/{self.jid}/ret", ) # Attempt to grab documentation if "fun" in low: @@ -330,7 +330,7 @@ class Runner(RunnerClient): # If we didn't get docs returned then # return the `not availble` message. if not ret: - ret = "{}".format(exc) + ret = f"{exc}" if not self.opts.get("quiet", False): display_output(ret, "nested", self.opts) else: diff --git a/tests/pytests/functional/cli/test_salt_run_.py b/tests/pytests/functional/cli/test_salt_run_.py index 66c28fc3aae..efc02e38da4 100644 --- a/tests/pytests/functional/cli/test_salt_run_.py +++ b/tests/pytests/functional/cli/test_salt_run_.py @@ -47,7 +47,7 @@ def test_versions_report(salt_run_cli): ret_lines = [line.strip() for line in ret_lines] for header in expected: - assert "{}:".format(header) in ret_lines + assert f"{header}:" in ret_lines ret_dict = {} expected_keys = set() diff --git a/tests/pytests/functional/states/test_user.py b/tests/pytests/functional/states/test_user.py index 96b1ec55c88..43ae8513012 100644 --- a/tests/pytests/functional/states/test_user.py +++ b/tests/pytests/functional/states/test_user.py @@ -348,7 +348,7 @@ def test_user_present_change_gid_but_keep_group( @pytest.mark.skip_unless_on_windows def test_user_present_existing(states, username): - win_profile = "C:\\User\\{}".format(username) + win_profile = f"C:\\User\\{username}" win_logonscript = "C:\\logon.vbs" win_description = "Test User Account" ret = states.user.present( @@ -360,7 +360,7 @@ def test_user_present_existing(states, username): ) assert ret.result is True - win_profile = "C:\\Users\\{}".format(username) + win_profile = f"C:\\Users\\{username}" win_description = "Temporary Account" ret = states.user.present( name=username,