From 56cabf33c66999fe3d289d6e3427d84504374fb3 Mon Sep 17 00:00:00 2001 From: gujishh Date: Sun, 12 Apr 2026 06:25:38 +0900 Subject: [PATCH] fix(cli): write saved output using UTF-8 encoding --- scripts/last30days.py | 2 +- tests/test_cli_v3.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/last30days.py b/scripts/last30days.py index 03b8a8f..0b95f24 100644 --- a/scripts/last30days.py +++ b/scripts/last30days.py @@ -103,7 +103,7 @@ def save_output(report: schema.Report, emit: str, save_dir: str, suffix: str = " content = emit_output(report, emit) else: content = render.render_full(report) - out_path.write_text(content) + out_path.write_text(content, encoding="utf-8") return out_path diff --git a/tests/test_cli_v3.py b/tests/test_cli_v3.py index 538e36f..1ebdeb2 100644 --- a/tests/test_cli_v3.py +++ b/tests/test_cli_v3.py @@ -128,6 +128,14 @@ class CliV3Tests(unittest.TestCase): payload = json.loads(path.read_text()) self.assertEqual("OpenClaw vs NanoClaw", payload["topic"]) + def test_save_output_writes_utf8_encoded_markdown(self): + report = self.make_report() + with tempfile.TemporaryDirectory() as tmp: + with mock.patch("pathlib.Path.write_text", autospec=True, return_value=1) as write_text: + cli.save_output(report, "md", tmp) + _, kwargs = write_text.call_args + self.assertEqual("utf-8", kwargs.get("encoding")) + def test_persist_report_updates_run_status_on_success_and_failure(self): report = self.make_report()