Make message.to_dict() return bytes for DATA type field (#386)
* change to_dict return bytes for DATA type * reformat * reformat * add includes .h --------- Co-authored-by: Brian Xu <brian.xu1@bytedance.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import capnp
|
||||
import base64
|
||||
import pytest
|
||||
|
||||
this_dir = os.path.dirname(__file__)
|
||||
@@ -14,7 +15,7 @@ def test_blob_to_dict(blob_schema):
|
||||
blob_value = b"hello world"
|
||||
blob = blob_schema.BlobTest(blob=blob_value)
|
||||
blob_dict = blob.to_dict(encode_bytes_as_base64=True)
|
||||
assert blob_dict["blob"].tobytes() == blob_value
|
||||
assert base64.b64decode(blob_dict["blob"]) == blob_value
|
||||
msg = blob_schema.BlobTest.new_message()
|
||||
msg.from_dict(blob_dict)
|
||||
assert blob.blob == blob_value
|
||||
|
||||
Reference in New Issue
Block a user