MCPcopy Create free account
hub / github.com/python-websockets/websockets / assertFrameSent

Method assertFrameSent

tests/test_protocol.py:31–55  ·  view source on GitHub ↗

Outgoing data for ``connection`` contains the given frame. ``frame`` may be ``None`` if no frame is expected. When ``eof`` is ``True``, the end of the stream is also expected.

(self, connection, frame, eof=False)

Source from the content-addressed store, hash-verified

29
30class ProtocolTestCase(FramesTestCase):
31 def assertFrameSent(self, connection, frame, eof=False):
32 """
33 Outgoing data for ``connection`` contains the given frame.
34
35 ``frame`` may be ``None`` if no frame is expected.
36
37 When ``eof`` is ``True``, the end of the stream is also expected.
38
39 """
40 frames_sent = [
41 (
42 None
43 if write is SEND_EOF
44 else self.parse(
45 write,
46 mask=connection.side is CLIENT,
47 extensions=connection.extensions,
48 )
49 )
50 for write in connection.data_to_send()
51 ]
52 frames_expected = [] if frame is None else [frame]
53 if eof:
54 frames_expected += [None]
55 self.assertEqual(frames_sent, frames_expected)
56
57 def assertFrameReceived(self, connection, frame):
58 """

Calls 2

data_to_sendMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected