diff --git a/tests/components/kira/test_init.py b/tests/components/kira/test_init.py index e57519667ce..8e6c70c83a4 100644 --- a/tests/components/kira/test_init.py +++ b/tests/components/kira/test_init.py @@ -1,6 +1,7 @@ """The tests for Kira.""" import os +from pathlib import Path import shutil import tempfile from unittest.mock import patch @@ -76,10 +77,9 @@ async def test_kira_creates_codes(work_dir) -> None: assert os.path.exists(code_path), "Kira component didn't create codes file" -async def test_load_codes(work_dir) -> None: +async def test_load_codes(hass: HomeAssistant, work_dir) -> None: """Kira should ignore invalid codes.""" code_path = os.path.join(work_dir, "codes.yaml") - with open(code_path, "w", encoding="utf8") as code_file: - code_file.write(KIRA_CODES) + await hass.async_add_executor_job(Path(code_path).write_text, KIRA_CODES) res = kira.load_codes(code_path) assert len(res) == 1, "Expected exactly 1 valid Kira code"