From 8f7d96b593f314f67ad23e86f212dbae64b45e67 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 20 Oct 2023 12:00:13 +0100 Subject: [PATCH] Apply `pyupgrade` on the changed files from the merge-forward Signed-off-by: Pedro Algarvio --- tests/pytests/integration/modules/test_pip.py | 6 +++--- tests/pytests/unit/states/saltmod/test_function.py | 6 ++---- tests/pytests/unit/utils/verify/test_clean_path_link.py | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/pytests/integration/modules/test_pip.py b/tests/pytests/integration/modules/test_pip.py index 141acc1806e..fd9294a182c 100644 --- a/tests/pytests/integration/modules/test_pip.py +++ b/tests/pytests/integration/modules/test_pip.py @@ -58,7 +58,7 @@ def _pip_successful_install( ) success_for = ( - re.findall(r"({})(?:-(?:[\d\.-]))?".format(expect_str), success.groups()[0]) + re.findall(rf"({expect_str})(?:-(?:[\d\.-]))?", success.groups()[0]) if success else [] ) @@ -540,7 +540,7 @@ def test_pip_install_multiple_editables(venv_dir, salt_cli, salt_minion): assert ret.returncode == 0 for package in ("iStr", "SaltTesting"): match = re.search( - r"(?:.*)(Successfully installed)(?:.*)({})(?:.*)".format(package), + rf"(?:.*)(Successfully installed)(?:.*)({package})(?:.*)", ret.stdout, ) assert match is not None @@ -580,7 +580,7 @@ def test_pip_install_multiple_editables_and_pkgs(venv_dir, salt_cli, salt_minion assert ret.returncode == 0 for package in ("iStr", "SaltTesting", "pep8"): match = re.search( - r"(?:.*)(Successfully installed)(?:.*)({})(?:.*)".format(package), + rf"(?:.*)(Successfully installed)(?:.*)({package})(?:.*)", ret.stdout, ) assert match is not None diff --git a/tests/pytests/unit/states/saltmod/test_function.py b/tests/pytests/unit/states/saltmod/test_function.py index 90b3e09d0e6..4ae53d99f7a 100644 --- a/tests/pytests/unit/states/saltmod/test_function.py +++ b/tests/pytests/unit/states/saltmod/test_function.py @@ -25,7 +25,7 @@ def test_function(): "name": name, "changes": {}, "result": None, - "comment": "Function state would be executed on target {}".format(tgt), + "comment": f"Function state would be executed on target {tgt}", } with patch.dict(saltmod.__opts__, {"test": True}): @@ -36,9 +36,7 @@ def test_function(): { "result": True, "changes": {"ret": {tgt: ""}}, - "comment": ( - "Function ran successfully. Function state ran on {}.".format(tgt) - ), + "comment": (f"Function ran successfully. Function state ran on {tgt}."), } ) with patch.dict(saltmod.__opts__, {"test": False}): diff --git a/tests/pytests/unit/utils/verify/test_clean_path_link.py b/tests/pytests/unit/utils/verify/test_clean_path_link.py index 8af20f5550a..ff83d1f54b3 100644 --- a/tests/pytests/unit/utils/verify/test_clean_path_link.py +++ b/tests/pytests/unit/utils/verify/test_clean_path_link.py @@ -55,7 +55,7 @@ def test_clean_path_symlinked_src(setup_links): test_path = from_path / "test" expect_path = str(to_path / "test") ret = salt.utils.verify.clean_path(str(from_path), str(test_path)) - assert ret == expect_path, "{} is not {}".format(ret, expect_path) + assert ret == expect_path, f"{ret} is not {expect_path}" def test_clean_path_symlinked_tgt(setup_links): @@ -63,4 +63,4 @@ def test_clean_path_symlinked_tgt(setup_links): test_path = to_path / "test" expect_path = str(to_path / "test") ret = salt.utils.verify.clean_path(str(from_path), str(test_path)) - assert ret == expect_path, "{} is not {}".format(ret, expect_path) + assert ret == expect_path, f"{ret} is not {expect_path}"