Fix blocking I/O in event loop in google_assistant test (#121126)

found by ruff in #120799
This commit is contained in:
J. Nick Koston
2024-07-03 15:35:23 -07:00
committed by GitHub
parent 595e688c56
commit 84d8bc711d

View File

@ -4,6 +4,7 @@ from datetime import UTC, datetime, timedelta
from http import HTTPStatus
import json
import os
from pathlib import Path
from typing import Any
from unittest.mock import ANY, patch
from uuid import uuid4
@ -655,9 +656,7 @@ async def test_async_get_users(
)
path = hass.config.config_dir / ".storage" / GoogleConfigStore._STORAGE_KEY
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, "w", encoding="utf8") as f:
f.write(store_data)
await hass.async_add_executor_job(Path(path).write_text, store_data)
assert await async_get_users(hass) == expected_users
await hass.async_stop()