Skip to content

Commit

Permalink
Make Pre-Commit happy
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhestkov committed Sep 22, 2023
1 parent 3f20ebc commit c8ac512
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions tests/pytests/unit/grains/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def _import_mock(name, *args):
), patch.object(
os.path, "exists", path_exists_mock
), patch(
"{}.__import__".format(built_in), side_effect=_import_mock
f"{built_in}.__import__", side_effect=_import_mock
), patch.object(
os.path, "isfile", path_isfile_mock
), patch.object(
Expand Down Expand Up @@ -528,7 +528,7 @@ def _import_mock(name, *args):
), patch.object(
os.path, "exists", path_exists_mock
), patch(
"{}.__import__".format(built_in), side_effect=_import_mock
f"{built_in}.__import__", side_effect=_import_mock
), patch.object(
os.path, "isfile", MagicMock(return_value=False)
), patch.object(
Expand Down Expand Up @@ -603,7 +603,7 @@ def _import_mock(name, *args):
), patch.object(
os.path, "exists", path_isfile_mock
), patch(
"{}.__import__".format(built_in), side_effect=_import_mock
f"{built_in}.__import__", side_effect=_import_mock
), patch.object(
os.path, "isfile", path_isfile_mock
), patch.object(
Expand Down Expand Up @@ -1679,7 +1679,7 @@ def test_docker_virtual(cgroup_substr):
"""
Test if virtual grains are parsed correctly in Docker.
"""
cgroup_data = "10:memory{}a_long_sha256sum".format(cgroup_substr)
cgroup_data = f"10:memory{cgroup_substr}a_long_sha256sum"
log.debug("Testing Docker cgroup substring '%s'", cgroup_substr)
with patch.object(os.path, "isdir", MagicMock(return_value=False)), patch.object(
os.path,
Expand Down Expand Up @@ -1814,7 +1814,7 @@ def _cmd_side_effect(cmd):
if cmd == "/usr/bin/zonename":
# NOTE: we return the name of the zone
return "myzone"
mylogdebug = "cmd.run_all: '{}'".format(cmd)
mylogdebug = f"cmd.run_all: '{cmd}'"
log.debug(mylogdebug)

def _cmd_all_side_effect(cmd):
Expand Down Expand Up @@ -1918,7 +1918,7 @@ def _check_ipaddress(value, ip_v):
"""
for val in value:
assert isinstance(val, str)
ip_method = "is_ipv{}".format(ip_v)
ip_method = f"is_ipv{ip_v}"
assert getattr(salt.utils.network, ip_method)(val)


Expand All @@ -1928,11 +1928,9 @@ def _check_empty(key, value, empty):
if empty is True and value exists assert error
"""
if not empty and not value:
raise Exception("{} is empty, expecting a value".format(key))
raise Exception(f"{key} is empty, expecting a value")
elif empty and value:
raise Exception(
"{} is suppose to be empty. value: {} exists".format(key, value)
)
raise Exception(f"{key} is suppose to be empty. value: {value} exists")


def _check_ip_fqdn_set(value, empty, _set=None):
Expand Down Expand Up @@ -2305,7 +2303,7 @@ def test_core_virtual():
"pid": 78,
"retcode": 0,
"stderr": "",
"stdout": "\n\n{}".format(virt),
"stdout": f"\n\n{virt}",
}
)
},
Expand Down

0 comments on commit c8ac512

Please sign in to comment.