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

Method encode

tests/legacy/test_framing.py:34–45  ·  view source on GitHub ↗
(self, frame, mask=False, extensions=None)

Source from the content-addressed store, hash-verified

32 return frame
33
34 def encode(self, frame, mask=False, extensions=None):
35 write = unittest.mock.Mock()
36 with warnings.catch_warnings():
37 warnings.simplefilter("ignore")
38 frame.write(write, mask=mask, extensions=extensions)
39 # Ensure the entire frame is sent with a single call to write().
40 # Multiple calls cause TCP fragmentation and degrade performance.
41 self.assertEqual(write.call_count, 1)
42 # The frame data is the single positional argument of that call.
43 self.assertEqual(len(write.call_args[0]), 1)
44 self.assertEqual(len(write.call_args[1]), 0)
45 return write.call_args[0][0]
46
47 def round_trip(self, message, expected, mask=False, extensions=None):
48 decoded = self.decode(message, mask, extensions=extensions)

Callers 15

round_tripMethod · 0.95
test_non_ascii_textMethod · 0.45
encodeMethod · 0.45
decodeMethod · 0.45
test_recv_textMethod · 0.45
test_recv_queue_emptyMethod · 0.45
test_recv_queue_fullMethod · 0.45

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected