mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
String formatting improvements for tests (#33663)
This commit is contained in:
@@ -30,8 +30,8 @@ class TestCommandSwitch(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as tempdirname:
|
||||
path = os.path.join(tempdirname, "switch_status")
|
||||
test_switch = {
|
||||
"command_on": "echo 1 > {}".format(path),
|
||||
"command_off": "echo 0 > {}".format(path),
|
||||
"command_on": f"echo 1 > {path}",
|
||||
"command_off": f"echo 0 > {path}",
|
||||
}
|
||||
assert setup_component(
|
||||
self.hass,
|
||||
@@ -64,9 +64,9 @@ class TestCommandSwitch(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as tempdirname:
|
||||
path = os.path.join(tempdirname, "switch_status")
|
||||
test_switch = {
|
||||
"command_state": "cat {}".format(path),
|
||||
"command_on": "echo 1 > {}".format(path),
|
||||
"command_off": "echo 0 > {}".format(path),
|
||||
"command_state": f"cat {path}",
|
||||
"command_on": f"echo 1 > {path}",
|
||||
"command_off": f"echo 0 > {path}",
|
||||
"value_template": '{{ value=="1" }}',
|
||||
}
|
||||
assert setup_component(
|
||||
@@ -102,9 +102,9 @@ class TestCommandSwitch(unittest.TestCase):
|
||||
oncmd = json.dumps({"status": "ok"})
|
||||
offcmd = json.dumps({"status": "nope"})
|
||||
test_switch = {
|
||||
"command_state": "cat {}".format(path),
|
||||
"command_on": "echo '{}' > {}".format(oncmd, path),
|
||||
"command_off": "echo '{}' > {}".format(offcmd, path),
|
||||
"command_state": f"cat {path}",
|
||||
"command_on": f"echo '{oncmd}' > {path}",
|
||||
"command_off": f"echo '{offcmd}' > {path}",
|
||||
"value_template": '{{ value_json.status=="ok" }}',
|
||||
}
|
||||
assert setup_component(
|
||||
@@ -138,9 +138,9 @@ class TestCommandSwitch(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as tempdirname:
|
||||
path = os.path.join(tempdirname, "switch_status")
|
||||
test_switch = {
|
||||
"command_state": "cat {}".format(path),
|
||||
"command_on": "echo 1 > {}".format(path),
|
||||
"command_off": "echo 0 > {}".format(path),
|
||||
"command_state": f"cat {path}",
|
||||
"command_on": f"echo 1 > {path}",
|
||||
"command_off": f"echo 0 > {path}",
|
||||
}
|
||||
assert setup_component(
|
||||
self.hass,
|
||||
|
||||
Reference in New Issue
Block a user