MCPcopy Create free account
hub / github.com/aio-libs/aiohttp / PatchableWebSocketReader

Class PatchableWebSocketReader

tests/test_websocket_parser.py:26–46  ·  view source on GitHub ↗

WebSocketReader subclass that allows for patching parse_frame.

Source from the content-addressed store, hash-verified

24
25
26class PatchableWebSocketReader(WebSocketReader):
27 """WebSocketReader subclass that allows for patching parse_frame."""
28
29 def parse_frame(
30 self, data: bytes
31 ) -> list[tuple[bool, int, bytes | bytearray, int]]:
32 # This method is overridden to allow for patching in tests.
33 frames: list[tuple[bool, int, bytes | bytearray, int]] = []
34
35 def _handle_frame(
36 fin: bool,
37 opcode: int,
38 payload: bytes | bytearray,
39 compressed: int,
40 ) -> None:
41 # This method is overridden to allow for patching in tests.
42 frames.append((fin, opcode, payload, compressed))
43
44 with mock.patch.object(self, "_handle_frame", _handle_frame):
45 self._feed_data(data)
46 return frames
47
48
49def build_frame(

Callers 3

parser_low_limitFunction · 0.85
parserFunction · 0.85

Calls

no outgoing calls

Tested by 3

parser_low_limitFunction · 0.68
parserFunction · 0.68