mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Fix blocking I/O in media_extractor tests (#121139)
This commit is contained in:
parent
cc2782edc7
commit
c59fc4e3c7
@ -290,16 +290,19 @@ async def test_cookiefile_detection(
|
|||||||
cookies_dir = os.path.join(hass.config.config_dir, "media_extractor")
|
cookies_dir = os.path.join(hass.config.config_dir, "media_extractor")
|
||||||
cookies_file = os.path.join(cookies_dir, "cookies.txt")
|
cookies_file = os.path.join(cookies_dir, "cookies.txt")
|
||||||
|
|
||||||
if not os.path.exists(cookies_dir):
|
def _write_cookies_file() -> None:
|
||||||
os.makedirs(cookies_dir)
|
if not os.path.exists(cookies_dir):
|
||||||
|
os.makedirs(cookies_dir)
|
||||||
|
|
||||||
with open(cookies_file, "w+", encoding="utf-8") as f:
|
with open(cookies_file, "w+", encoding="utf-8") as f:
|
||||||
f.write(
|
f.write(
|
||||||
"""# Netscape HTTP Cookie File
|
"""# Netscape HTTP Cookie File
|
||||||
|
|
||||||
.youtube.com TRUE / TRUE 1701708706 GPS 1
|
.youtube.com TRUE / TRUE 1701708706 GPS 1
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await hass.async_add_executor_job(_write_cookies_file)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -314,7 +317,7 @@ async def test_cookiefile_detection(
|
|||||||
|
|
||||||
assert "Media extractor loaded cookies file" in caplog.text
|
assert "Media extractor loaded cookies file" in caplog.text
|
||||||
|
|
||||||
os.remove(cookies_file)
|
await hass.async_add_executor_job(os.remove, cookies_file)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user