Skip to content

The agent that grows with you

chore(tests): explicit utf-8 encoding in test_claw (windows-footgun ratchet)

teknium107ead2249b0d
diff --git a/tests/hermes_cli/test_claw.py b/tests/hermes_cli/test_claw.py
index 5cf10586874..1cacde20cf9 100644
--- a/tests/hermes_cli/test_claw.py
+++ b/tests/hermes_cli/test_claw.py
@@ -20,7 +20,7 @@ class TestFindMigrationScript:
def test_finds_project_root_script(self, tmp_path):
script = tmp_path / "openclaw_to_hermes.py"
- script.write_text("# placeholder")
+ script.write_text("# placeholder", encoding="utf-8")
with patch.object(claw_mod, "_OPENCLAW_SCRIPT", script):
assert claw_mod._find_migration_script() == script
@@ -61,7 +61,7 @@ class TestScanWorkspaceState:
"""Test scanning for workspace state files."""
def test_finds_root_state_files(self, tmp_path):
- (tmp_path / "todo.json").write_text("{}")
+ (tmp_path / "todo.json").write_text("{}", encoding="utf-8")
(tmp_path / "sessions").mkdir()
findings = claw_mod._scan_workspace_state(tmp_path)
descs = [desc for _, desc in findings]
@@ -74,7 +74,7 @@ class TestScanWorkspaceState:
scan_dir.mkdir()
hidden = scan_dir / ".git"
hidden.mkdir()
- (hidden / "todo.json").write_text("{}")
+ (hidden / "todo.json").write_text("{}", encoding="utf-8")
findings = claw_mod._scan_workspace_state(scan_dir)
assert len(findings) == 0
@@ -90,13 +90,13 @@ class TestArchiveDirectory:
def test_renames_to_pre_migration(self, tmp_path):
source = tmp_path / ".openclaw"
source.mkdir()
- (source / "test.txt").write_text("data")
+ (source / "test.txt").write_text("data", encoding="utf-8")
archive_path = claw_mod._archive_directory(source)
assert archive_path == tmp_path / ".openclaw.pre-migration"
assert archive_path.is_dir()
assert not source.exists()
- assert (archive_path / "test.txt").read_text() == "data"
+ assert (archive_path / "test.txt").read_text(encoding="utf-8") == "data"
def test_adds_timestamp_when_archive_exists(self, tmp_path):
source = tmp_path / ".openclaw"
@@ -167,7 +167,7 @@ class TestCmdMigrate:
openclaw_dir = tmp_path / ".openclaw"
openclaw_dir.mkdir()
config_path = tmp_path / "config.yaml"
- config_path.write_text("")
+ config_path.write_text("", encoding="utf-8")
args = Namespace(
source=str(openclaw_dir),
@@ -286,7 +286,7 @@ class TestCmdCleanup:
openclaw.mkdir()
ws = openclaw / "workspace"
ws.mkdir()
- (ws / "todo.json").write_text("{}")
+ (ws / "todo.json").write_text("{}", encoding="utf-8")
args = Namespace(source=None, dry_run=True, yes=False)
with patch.object(claw_mod, "_find_openclaw_dirs", return_value=[openclaw]):
@@ -300,7 +300,7 @@ class TestCmdCleanup:
def test_explicit_source(self, tmp_path, capsys):
custom_dir = tmp_path / "my-openclaw"
custom_dir.mkdir()
- (custom_dir / "todo.json").write_text("{}")
+ (custom_dir / "todo.json").write_text("{}", encoding="utf-8")
args = Namespace(source=str(custom_dir), dry_run=False, yes=True)
claw_mod._cmd_cleanup(args)