fix(issue-45): restore stays off when python3 has no tomllib

The shim runs a bare python3. Before 3.11 the module failed to import and the
server started with restore on; now it gets the key alone, with a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GodopuandClaude Opus 5.5 committed 2026-10-04 10:34:27 +00:00
1 parent feceddf49f
commit eedcebcc12
2 files changed
+16 -1

No files matched your search

+8
View File
@@ -71,6 +71,14 @@ def test_a_bad_value_type_falls_back_to_minimal():
assert warnings == []
def test_without_tomllib_restore_is_still_off(monkeypatch):
# The shim runs a bare `python3`; on one older than 3.11 an import error
# would leave the server with restore on. Off wins over the user's settings.
monkeypatch.setattr(hc, "tomllib", None)
text, warnings = hc.server_config_text("[ui]\nconfirm_close = false\n")
assert text == hc.MINIMAL and "no tomllib" in warnings[0]
def _env(tmp_path, **kw):
env = {"HOME": str(tmp_path / "home")}
env.update(kw)