AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).
test(orchestrator): stop two fixtures leaking current_session (#229)
Rufusafacac93810a
diff --git a/CLAUDE.md b/CLAUDE.mdindex 4e645770..8853f4c0 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -183,6 +183,14 @@ See `.env.example`. Required: `ANTHROPIC_API_KEY`, `EXEC_EMAIL_ADDRESS` (no defa> "handled overnight" block). Patch it in an autouse fixture, and delete a> stray `packages/core/episodic_memory.db` (gitignored) if one appears.+> **ContextVar leaks between tests:** a *sync* fixture or test that sets+> `current_session` (or any module-level ContextVar) and doesn't reset it+> leaves that value bound for every later test in the process.+> pytest-asyncio isolates only async tests and fixtures. Use+> `token = var.set(...)`, `yield`, `var.reset(token)`. CI's `-n auto --dist+> loadfile` usually puts the leaking file and the one it breaks on different+> workers, so only a serial run (no `-n`) shows it.+> **Pre-existing ruff hits in `tests/unit/test_attachments.py`** (unsorted> imports, unused `asyncio`): `make lint` only checks `openexecutive/`, so CI> is unaffected — lint the specific test files you touched rather thandiff --git a/packages/core/tests/unit/test_schedule_tool_handler.py b/packages/core/tests/unit/test_schedule_tool_handler.pyindex 39056f13..d2959fe9 100644--- a/packages/core/tests/unit/test_schedule_tool_handler.py+++ b/packages/core/tests/unit/test_schedule_tool_handler.py@@ -7,6 +7,7 @@ from __future__ import annotationsimport asyncioimport json+from collections.abc import Iteratorfrom datetime import UTC, datetime, timedeltafrom pathlib import Path@@ -29,11 +30,12 @@ def isolated_db(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:@pytest.fixture()-def session_with_telegram_ref() -> Session:+def session_with_telegram_ref() -> Iterator[Session]:s = Session()s.seen_channel_refs.add(("telegram", "42"))- current_session.set(s)- return s+ token = current_session.set(s)+ yield s+ current_session.reset(token)def _future_iso(seconds: int = 600) -> str:diff --git a/packages/core/tests/unit/test_suggest_workflow_handler.py b/packages/core/tests/unit/test_suggest_workflow_handler.pyindex e66a900a..8210e01a 100644--- a/packages/core/tests/unit/test_suggest_workflow_handler.py+++ b/packages/core/tests/unit/test_suggest_workflow_handler.py@@ -10,6 +10,7 @@ import asyncioimport base64import jsonimport os+from collections.abc import Iteratorfrom datetime import UTC, datetime, timedeltafrom pathlib import Pathfrom typing import Any@@ -36,11 +37,12 @@ def isolated_db(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:@pytest.fixture()-def session_with_telegram_ref() -> Session:+def session_with_telegram_ref() -> Iterator[Session]:s = Session()s.seen_channel_refs.add(("telegram", "42"))- current_session.set(s)- return s+ token = current_session.set(s)+ yield s+ current_session.reset(token)def _future_iso(seconds: int = 600) -> str: