Private
Public Access
0
0

fix(test_gui_context_presets): open sloppy_py_test.log in binary mode

The test's debug "print background log" code opened the file
in text mode with utf-8 encoding. The sloppy.py GUI process writes
Windows console output that includes cp1252-encoded bytes (e.g.,
0x97 in position 1704 in the captured failure). Opening in text
mode raises UnicodeDecodeError on the first non-utf-8 byte.

Fix: open in binary mode and decode with errors='replace' so the
print is best-effort and never crashes the test.

This is a test-only fix. Production code paths unchanged.
This commit is contained in:
2026-06-07 14:43:36 -04:00
parent c21ca43489
commit 9a1bcba3e8
+6 -3
View File
@@ -45,11 +45,14 @@ def test_gui_context_preset_save_load(live_gui) -> None:
client.push_event("custom_callback", {"callback": "load_context_preset", "args": [preset_name]})
time.sleep(1.0)
# DEBUG: Print the background process log
# DEBUG: Print the background process log (binary mode because the
# GUI process writes Windows console output that isn't valid UTF-8)
log_path = os.path.join("logs", "sloppy_py_test.log")
if os.path.exists(log_path):
with open(log_path, "r", encoding="utf-8") as f:
print(f"BACKGROUND LOG:\n{f.read()}")
with open(log_path, "rb") as f:
raw = f.read()
text = raw.decode("utf-8", errors="replace")
print(f"BACKGROUND LOG:\n{text}")
context = client.get_context_state()
loaded_files = [f["path"] if isinstance(f, dict) else str(f) for f in context.get("files", [])]