MCPcopy Index your code
hub / github.com/nonebot/nonebot2 / test_aiohttp_websocket_close_frame

Function test_aiohttp_websocket_close_frame

tests/test_driver.py:683–707  ·  view source on GitHub ↗
(msg_type: str)

Source from the content-addressed store, hash-verified

681 ],
682)
683async def test_aiohttp_websocket_close_frame(msg_type: str) -> None:
684 class DummyWS(ClientWebSocketResponse):
685 def __init__(self) -> None:
686 pass
687
688 @property
689 def close_code(self) -> None:
690 return None
691
692 @property
693 def closed(self) -> bool:
694 return True
695
696 async def receive(self, timeout: float | None = None) -> WSMessage: # noqa: ASYNC109
697 return WSMessage(type=WSMsgType[msg_type], data=None, extra=None)
698
699 async with ClientSession() as session:
700 ws = AiohttpWebSocket(
701 request=Request("GET", "ws://example.com"),
702 session=session,
703 websocket=DummyWS(),
704 )
705
706 with pytest.raises(WebSocketClosed, match=r"code=1006"):
707 await ws.receive()
708
709
710def test_timeout_unset_vs_none():

Callers

nothing calls this directly

Calls 3

DummyWSClass · 0.85
RequestClass · 0.50
receiveMethod · 0.45

Tested by

no test coverage detected