def test_wire_protocol(self): for i, handler in enumerate(Message._types): one = py.io.BytesIO() data = '23'.encode('ascii') Message(i, 42, data).to_io(one) two = py.io.BytesIO(one.getvalue()) msg = Message.from_io(two) assert msg.msgcode == i assert isinstance(msg, Message) assert msg.channelid == 42 assert msg.data == data assert isinstance(repr(msg), str)