Update local_todo to explicitly specify UTF-8 encoding for ICS storage (#181578)

This commit is contained in:
Allen Porter
2026-09-08 10:49:28 +02:00
committed by GitHub
parent fd8a165c97
commit 84583b8bf3
3 changed files with 9 additions and 3 deletions
+2 -2
View File
@@ -24,7 +24,7 @@ class LocalTodoListStore:
"""Load the calendar from disk."""
if not self._path.exists():
return ""
return self._path.read_text()
return self._path.read_text(encoding="utf-8")
async def async_store(self, ics_content: str) -> None:
"""Persist the calendar to storage."""
@@ -33,4 +33,4 @@ class LocalTodoListStore:
def _store(self, ics_content: str) -> None:
"""Persist the calendar to storage."""
self._path.write_text(ics_content)
self._path.write_text(ics_content, encoding="utf-8")
+3 -1
View File
@@ -55,7 +55,9 @@ class FakeStore(LocalTodoListStore):
def _mock_exists(self) -> bool:
return self._mock_path.read_text.return_value is not None
def _mock_write_text(self, content: str) -> None:
def _mock_write_text(self, content: str, encoding: str | None = None) -> None:
if encoding is None:
content.encode("ascii")
self._mock_path.read_text.return_value = content
+4
View File
@@ -98,6 +98,10 @@ EXPECTED_ADD_ITEM = {
),
({ATTR_DESCRIPTION: ""}, {**EXPECTED_ADD_ITEM, "description": ""}),
({ATTR_DESCRIPTION: None}, EXPECTED_ADD_ITEM),
(
{ATTR_ITEM: "测试主卧清扫"},
{**EXPECTED_ADD_ITEM, "summary": "测试主卧清扫"},
),
],
)
async def test_add_item(