MCPcopy Create free account
hub / github.com/apache/fory / struct_round_back

Function struct_round_back

python/pyfory/tests/test_cross_language.py:598–612  ·  view source on GitHub ↗
(data_file_path, fory, obj1)

Source from the content-addressed store, hash-verified

596
597
598def struct_round_back(data_file_path, fory, obj1):
599 # new_buf = fory.serialize(obj1)
600 # assert fory.deserialize(new_buf) == obj1
601 with open(data_file_path, "rb") as f:
602 data_bytes = f.read()
603 debug_print(f"len {len(data_bytes)}")
604 debug_print(f"first 100 bytes: {data_bytes[:100].hex()}")
605 new_obj = fory.deserialize(data_bytes)
606 debug_print(new_obj)
607 _assert_deep_equal(new_obj, obj1, "struct_round_back mismatch: ")
608 new_buf = fory.serialize(new_obj)
609 debug_print(f"new_buf size {len(new_buf)}")
610 _assert_deep_equal(fory.deserialize(new_buf), new_obj, "round-trip mismatch: ")
611 with open(data_file_path, "wb+") as f:
612 f.write(new_buf)
613
614
615class ComplexObject1Serializer(pyfory.serializer.Serializer):

Callers 5

test_register_by_idFunction · 0.85
test_enum_fieldFunction · 0.85

Calls 7

_assert_deep_equalFunction · 0.85
hexMethod · 0.80
debug_printFunction · 0.70
readMethod · 0.65
deserializeMethod · 0.65
serializeMethod · 0.65
writeMethod · 0.65

Tested by

no test coverage detected