Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/test_coding_tools.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import shlex
import sys
from pathlib import Path
from time import monotonic

Expand Down Expand Up @@ -160,6 +161,14 @@ async def test_bash_tool_captures_stdout_and_exit_code(tmp_path: Path) -> None:
assert result.data["timed_out"] is False


# These tests rely on bash behavior (shell_command_prefix routes through bash,
# and job control like `sleep 1 & wait`) that only applies on POSIX.
requires_posix_shell = pytest.mark.skipif(
sys.platform == "win32", reason="bash-specific shell behavior is POSIX-only"
)


@requires_posix_shell
@pytest.mark.anyio
async def test_create_coding_tools_applies_shell_command_prefix(
tmp_path: Path,
Expand All @@ -178,6 +187,7 @@ async def test_create_coding_tools_applies_shell_command_prefix(
assert result.data["shell_command_prefix_applied"] is True


@requires_posix_shell
@pytest.mark.anyio
async def test_bash_tool_applies_opt_in_shell_command_prefix(tmp_path: Path) -> None:
rc_path = tmp_path / ".zshrc"
Expand Down Expand Up @@ -227,6 +237,7 @@ async def test_bash_tool_timeout_kills_shell_children(tmp_path: Path) -> None:
assert not marker.exists()


@requires_posix_shell
@pytest.mark.anyio
async def test_bash_tool_cancellation_kills_shell_children(tmp_path: Path) -> None:
tool = create_bash_tool(cwd=tmp_path)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_credentials.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from stat import S_IMODE

import pytest
Expand All @@ -12,7 +13,9 @@ def test_file_credential_store_round_trips_and_sets_private_permissions(tmp_path
store.set("openai", "test-key")

assert store.get("openai") == "test-key"
assert S_IMODE(path.stat().st_mode) == 0o600
if os.name == "posix":
# chmod(0o600) is a no-op for these bits on Windows filesystems.
assert S_IMODE(path.stat().st_mode) == 0o600


def test_file_credential_store_deletes_key(tmp_path) -> None:
Expand Down
4 changes: 3 additions & 1 deletion tests/test_system_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def test_default_prompt_includes_tools_guidelines_date_and_cwd(tmp_path: Path) -
assert "Available tools:\n- read: Read file contents" in prompt
assert "- Use bash for file operations like ls, rg, find" in prompt
assert "- Use read to examine files instead of cat or sed." in prompt
assert prompt.endswith(f"Current date: 2026-06-17\nCurrent working directory: {tmp_path}")
# build_system_prompt normalizes the cwd to forward slashes on every platform.
expected_cwd = str(tmp_path).replace("\\", "/")
assert prompt.endswith(f"Current date: 2026-06-17\nCurrent working directory: {expected_cwd}")


def test_tool_without_prompt_snippet_is_hidden_from_available_tools() -> None:
Expand Down
13 changes: 8 additions & 5 deletions tests/test_tui_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,10 @@ def test_session_sidebar_lists_multiple_context_files() -> None:
console.print(render_session_sidebar(session))

output = console.export_text()
# The sidebar renders labels via str(Path(...)), so separators are native.
assert "AGENTS.md" in output
assert ".agents/AGENTS.md" in output
assert "docs/AGENTS.md" in output
assert str(Path(".agents") / "AGENTS.md") in output
assert str(Path("docs") / "AGENTS.md") in output


def test_compact_session_info_renders_sidebar_facts() -> None:
Expand All @@ -481,7 +482,7 @@ def test_compact_session_info_renders_sidebar_facts() -> None:
console.print(render_compact_session_info(FakeSession()))

output = console.export_text()
assert "/workspace/project (--)" in output
assert f"{Path('/workspace/project')} (--)" in output
assert "12k/200k context" in output
assert "openai:fake-model" in output
assert "(medium)" in output
Expand Down Expand Up @@ -2648,7 +2649,9 @@ def fake_notify(message: str, **kwargs: object) -> None:
await pilot.press("enter")

assert session.export_calls == [(Path("out.jsonl"), "jsonl")]
assert notifications == ["Exported session to /workspace/project/session.html"]
assert notifications == [
f"Exported session to {Path('/workspace/project/session.html')}"
]
assert session.prompt_texts == []


Expand Down Expand Up @@ -2911,7 +2914,7 @@ async def test_tui_app_completes_resume_session_argument() -> None:

assert app._completion_state.selected is not None
assert app._completion_state.selected.description == (
"Session - fake-model - /workspace/project"
f"Session - fake-model - {Path('/workspace/project')}"
)

await pilot.press("tab")
Expand Down