def test_msg_pack_unpack(): """ Make sure pack_msg_type and unpack_msg_type work correctly. """ data = pack_msg_type(6, b'abcdefg') msg_type, msg_data = unpack_msg_type(data) assert msg_type == 6 assert msg_data == b'abcdefg'
def test_msg_pack_unpack(): """ Make sure pack_msg_type and unpack_msg_type work correctly. """ data = pack_msg_type(6,b'abcdefg') msg_type, msg_data = unpack_msg_type(data) assert msg_type == 6 assert msg_data == b'abcdefg'
def test_msg_pack_unpack_error(): """ Check handling of errors with pack_msg_type and unpack_msg_type """ # We can't unpack data that is too short: with pytest.raises(DeserializeError): unpack_msg_type(b'12') with pytest.raises(DeserializeError): unpack_msg_type(b'123') # This one doesn't raise an exception: unpack_msg_type(b'1234') with pytest.raises(DeserializeError): unpack_msg_type(b'123')
def test_msg_pack_unpack_error(): """ Check handling of errors with pack_msg_type and unpack_msg_type """ # We can't unpack data that is too short: with pytest.raises(DeserializeError): unpack_msg_type(b'12') with pytest.raises(DeserializeError): unpack_msg_type(b'123') # This one doesn't raise an exception: unpack_msg_type(b'1234') with pytest.raises(DeserializeError): unpack_msg_type(b'123')