示例#1
0
    def test_writer_send(self):
        transport = BytesIO()
        ww = WebSocketWriter(transport)
        ww.send(b'Hello')
        transport.seek(0)
        self.assertEqual(transport.read(), b'\x82\x05Hello')

        transport = BytesIO()
        ww = WebSocketWriter(transport)
        ww.send('пы')
        transport.seek(0)
        self.assertEqual(transport.read(), b'\x81\x04\xd0\xbf\xd1\x8b')
示例#2
0
 def test_writer_close(self):
     transport = BytesIO()
     ww = WebSocketWriter(transport)
     ww.close()
     transport.seek(0)
     self.assertEqual(transport.read(), FrameBuilder.close(masked=False))