From 44b6ab90ed75e01141f4c22963480a99ca8f29c9 Mon Sep 17 00:00:00 2001 From: worldmozara Date: Mon, 26 Oct 2026 00:52:38 +0800 Subject: [PATCH] test: cover the scratch hint in the escape refusal One test for the write path that now names `new_temporary_workspace`, one parametrized over read and exec, which must not. --- tests/test_tools/test_workspace.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_tools/test_workspace.py b/tests/test_tools/test_workspace.py index b9cccfd..fbd8a3a 100644 --- a/tests/test_tools/test_workspace.py +++ b/tests/test_tools/test_workspace.py @@ -50,6 +50,21 @@ def test_escape_error_names_the_mode_to_request(workspace: object, required: Acc _ = resolve_path("../outside", required=required) +def test_escape_error_offers_a_temporary_workspace_for_a_write(workspace: object) -> None: + """A refused write is often scratch, which never needs a grant.""" + del workspace + with pytest.raises(WorkspaceError, match="new_temporary_workspace"): + _ = resolve_path("../scratch.txt", required=AccessMode.WRITE) + + +@pytest.mark.parametrize("required", [AccessMode.READ, AccessMode.EXEC]) +def test_escape_error_hides_the_scratch_hint_from_other_modes(workspace: object, required: AccessMode) -> None: + del workspace + with pytest.raises(WorkspaceError) as refusal: + _ = resolve_path("../scratch.txt", required=required) + assert "new_temporary_workspace" not in str(refusal.value) + + def test_access_mode_parse_and_covers() -> None: assert parse_access_mode(" Read ") is AccessMode.READ assert parse_access_mode("EXEC") is AccessMode.EXEC