Fix blocking I/O in media_extractor tests (#121139)

This commit is contained in:
J. Nick Koston 2024-07-03 23:08:53 -05:00 committed by GitHub
parent cc2782edc7
commit c59fc4e3c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -290,6 +290,7 @@ async def test_cookiefile_detection(
cookies_dir = os.path.join(hass.config.config_dir, "media_extractor")
cookies_file = os.path.join(cookies_dir, "cookies.txt")
def _write_cookies_file() -> None:
if not os.path.exists(cookies_dir):
os.makedirs(cookies_dir)
@ -301,6 +302,8 @@ async def test_cookiefile_detection(
"""
)
await hass.async_add_executor_job(_write_cookies_file)
await hass.services.async_call(
DOMAIN,
SERVICE_PLAY_MEDIA,
@ -314,7 +317,7 @@ async def test_cookiefile_detection(
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(
DOMAIN,