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

Function test_decimal

python/pyfory/tests/xlang_test_main.py:813–833  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

811
812
813def test_decimal():
814 data_file = get_data_file()
815 with open(data_file, "rb") as f:
816 data_bytes = f.read()
817
818 buffer = pyfory.Buffer(data_bytes)
819 fory = pyfory.Fory(xlang=True, compatible=True)
820 expected_values = decimal_values()
821 actual_values = []
822 for expected in expected_values:
823 value = fory.deserialize(buffer)
824 debug_print(f"Deserialized decimal: {value!r}")
825 assert isinstance(value, decimal.Decimal)
826 assert value.as_tuple() == expected.as_tuple(), f"Mismatch: {value!r} != {expected!r}"
827 actual_values.append(value)
828
829 new_buffer = pyfory.Buffer.allocate(max(256, len(data_bytes) * 2))
830 for value in actual_values:
831 fory.serialize(value, buffer=new_buffer)
832 with open(data_file, "wb") as f:
833 f.write(new_buffer.get_bytes(0, new_buffer.get_writer_index()))
834
835
836def test_schema_evolution_compatible():

Callers

nothing calls this directly

Calls 12

deserializeMethod · 0.95
serializeMethod · 0.95
decimal_valuesFunction · 0.85
get_bytesMethod · 0.80
get_data_fileFunction · 0.70
debug_printFunction · 0.70
readMethod · 0.65
allocateMethod · 0.65
writeMethod · 0.65
BufferMethod · 0.45
ForyMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected