MCPcopy Index your code
hub / github.com/python-websockets/websockets / RecordingProtocol

Class RecordingProtocol

tests/protocol.py:4–29  ·  view source on GitHub ↗

Protocol subclass that records incoming frames. By interfacing with this protocol, you can check easily what the component being testing sends during a test.

Source from the content-addressed store, hash-verified

2
3
4class RecordingProtocol(Protocol):
5 """
6 Protocol subclass that records incoming frames.
7
8 By interfacing with this protocol, you can check easily what the component
9 being testing sends during a test.
10
11 """
12
13 def __init__(self, *args, **kwargs):
14 super().__init__(*args, **kwargs)
15 self.frames_rcvd = []
16
17 def get_frames_rcvd(self):
18 """
19 Get incoming frames received up to this point.
20
21 Calling this method clears the list. Each frame is returned only once.
22
23 """
24 frames_rcvd, self.frames_rcvd = self.frames_rcvd, []
25 return frames_rcvd
26
27 def recv_frame(self, frame):
28 self.frames_rcvd.append(frame)
29 super().recv_frame(frame)

Callers 2

asyncSetUpMethod · 0.85
setUpMethod · 0.85

Calls

no outgoing calls

Tested by 2

asyncSetUpMethod · 0.68
setUpMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…