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

Function test_struct_hash

python/pyfory/tests/test_cross_language.py:507–524  ·  view source on GitHub ↗
(data_file_path)

Source from the content-addressed store, hash-verified

505
506@cross_language_test
507def test_struct_hash(data_file_path):
508 with open(data_file_path, "rb") as f:
509 data_bytes = f.read()
510 debug_print(f"len {len(data_bytes)}")
511 read_hash = pyfory.Buffer(data_bytes).read_int32()
512 fory = pyfory.Fory(xlang=True, compatible=False, ref=True)
513 fory.register_type(ComplexObject1, name="ComplexObject1")
514 serializer = fory.type_resolver.get_serializer(ComplexObject1)._replace()
515 from pyfory.struct import compute_struct_meta
516
517 v = compute_struct_meta(
518 fory.type_resolver,
519 serializer._field_names,
520 serializer._serializers,
521 serializer._nullable_fields,
522 serializer._field_infos,
523 )[0]
524 assert read_hash == v, (read_hash, v)
525
526
527@cross_language_test

Callers

nothing calls this directly

Calls 9

register_typeMethod · 0.95
compute_struct_metaFunction · 0.90
_replaceMethod · 0.80
get_serializerMethod · 0.80
debug_printFunction · 0.70
readMethod · 0.65
read_int32Method · 0.45
BufferMethod · 0.45
ForyMethod · 0.45

Tested by

no test coverage detected