diff --git a/agent-team/tests/test_slack_live.py b/agent-team/tests/test_slack_live.py index 48dfdf1..6d3fbf8 100644 --- a/agent-team/tests/test_slack_live.py +++ b/agent-team/tests/test_slack_live.py @@ -214,7 +214,19 @@ def test_poster_unsupported_response_raises_type_error() -> None: def test_missing_token_raises_runtime_error(monkeypatch: pytest.MonkeyPatch) -> None: - """No token and no SLACK_BOT_TOKEN raises a clear RuntimeError.""" + """No token and no SLACK_BOT_TOKEN raises a clear RuntimeError. + + Stub ``slack_sdk`` into ``sys.modules`` so the deferred import SUCCEEDS and + the no-token branch is what's under test. Without this the test is + environment-dependent: where slack_sdk is absent (CI) the import-missing + error fires first and masks the token check (local-vs-CI drift). + """ + import sys + from types import ModuleType + + fake = ModuleType("slack_sdk") + fake.WebClient = lambda **kw: None # type: ignore[attr-defined] + monkeypatch.setitem(sys.modules, "slack_sdk", fake) monkeypatch.delenv("SLACK_BOT_TOKEN", raising=False) with pytest.raises(RuntimeError, match="Slack bot token"):