diff --git a/nanobot/channels/weixin.py b/nanobot/channels/weixin.py index cd46775f9..dff830613 100644 --- a/nanobot/channels/weixin.py +++ b/nanobot/channels/weixin.py @@ -951,7 +951,7 @@ class WeixinChannel(BaseChannel): ctx_token = self._context_tokens.get(msg.chat_id, "") if not ctx_token: raise RuntimeError( - f"No context_token for chat_id={msg.chat_id}, cannot send" + f"WeChat context_token missing for chat_id={msg.chat_id}, cannot send" ) typing_ticket = "" diff --git a/tests/channels/test_weixin_channel.py b/tests/channels/test_weixin_channel.py index 1cfeb9dd3..1ca814561 100644 --- a/tests/channels/test_weixin_channel.py +++ b/tests/channels/test_weixin_channel.py @@ -325,7 +325,7 @@ async def test_send_without_context_token_raises() -> None: channel._token = "token" channel._send_text = AsyncMock() - with pytest.raises(RuntimeError, match="No context_token"): + with pytest.raises(RuntimeError, match="context_token missing"): await channel.send( type("Msg", (), {"chat_id": "unknown-user", "content": "pong", "media": [], "metadata": {}})() ) @@ -1227,7 +1227,7 @@ async def test_send_text_raises_on_api_error() -> None: """_send_text must raise RuntimeError when the API returns a non-zero errcode, matching _send_media_file behavior. This ensures ChannelManager can retry.""" channel, _bus = _make_channel() - channel._client = httpx.AsyncClient() + channel._client = object() channel._token = "token" channel._api_post = AsyncMock( return_value={"errcode": -14, "errmsg": "session expired"} @@ -1243,7 +1243,7 @@ async def test_send_text_raises_on_api_error() -> None: async def test_send_text_succeeds_on_zero_errcode() -> None: """_send_text must NOT raise when errcode is 0.""" channel, _bus = _make_channel() - channel._client = httpx.AsyncClient() + channel._client = object() channel._token = "token" channel._api_post = AsyncMock(return_value={"errcode": 0})