Skip to content

Your lightweight open-source personal agent.

test: stabilize flaky and environment-dependent tests

KDBdb918bddd315
diff --git a/tests/agent/conftest.py b/tests/agent/conftest.py
index bb8ec7db7..ec0f5aac7 100644
--- a/tests/agent/conftest.py
+++ b/tests/agent/conftest.py
@@ -35,7 +35,7 @@ def make_provider(
temperature=0.1,
reasoning_effort=None,
)
- provider.estimate_prompt_tokens.return_value = (10_000, "test")
+ provider.estimate_prompt_tokens = MagicMock(return_value=(10_000, "test"))
return provider
diff --git a/tests/providers/test_oauth_model_catalog.py b/tests/providers/test_oauth_model_catalog.py
index d9582e6a6..bfb7060fd 100644
--- a/tests/providers/test_oauth_model_catalog.py
+++ b/tests/providers/test_oauth_model_catalog.py
@@ -387,10 +387,16 @@ def test_catalog_bounds_failure_only_keys() -> None:
calls += 1
raise httpx.ConnectError("offline")
+ # Real monotonic time can serve identical timestamps to all three
+ # lookups, making the eviction victim in _reserve() depend on set
+ # iteration order (hash-seeded). A synthetic strictly-increasing clock
+ # pins the oldest entry deterministically.
+ ticks = iter(range(10_000))
catalog = OAuthModelCatalog(
fallback_models=(_fallback_model(),),
fetch=fetch,
max_entries=2,
+ monotonic=lambda: float(next(ticks)),
)
for key in ("one", "two", "three"):
diff --git a/tests/session/test_session_location.py b/tests/session/test_session_location.py
index c041152d4..38c850064 100644
--- a/tests/session/test_session_location.py
+++ b/tests/session/test_session_location.py
@@ -193,7 +193,11 @@ def test_equivalent_workspace_paths_share_one_store(tmp_path: Path) -> None:
real_workspace = tmp_path / "real_ws"
real_workspace.mkdir()
link_workspace = tmp_path / "link_ws"
- link_workspace.symlink_to(real_workspace, target_is_directory=True)
+ try:
+ link_workspace.symlink_to(real_workspace, target_is_directory=True)
+ except OSError as exc:
+ # Creating directory symlinks needs admin/developer mode on Windows.
+ pytest.skip(f"directory symlink unavailable: {exc}")
# Save via the real path, then read via a symlink to the same directory.
manager = SessionManager(workspace=real_workspace)