Protocol subclass that records incoming frames. By interfacing with this protocol, you can check easily what the component being testing sends during a test.
| 2 | |
| 3 | |
| 4 | class 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) |
no outgoing calls
searching dependent graphs…