Skip to content

Commit

Permalink
Fix blocking I/O in event loop in core test (home-assistant#121128)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Jul 4, 2024
1 parent 0e9acf2 commit 8a5b201
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import gc
import logging
import os
from pathlib import Path
import re
from tempfile import TemporaryDirectory
import threading
Expand Down Expand Up @@ -2009,8 +2010,9 @@ async def test_config_is_allowed_path() -> None:
config.allowlist_external_dirs = {os.path.realpath(tmp_dir)}

test_file = os.path.join(tmp_dir, "test.jpg")
with open(test_file, "w", encoding="utf8") as tmp_file:
tmp_file.write("test")
await asyncio.get_running_loop().run_in_executor(
None, Path(test_file).write_text, "test"
)

valid = [test_file, tmp_dir, os.path.join(tmp_dir, "notfound321")]
for path in valid:
Expand Down

0 comments on commit 8a5b201

Please sign in to comment.