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

Function test_serialization_without_schema

python/pyfory/tests/test_cross_language.py:176–200  ·  view source on GitHub ↗
(data_file_path, schema=None)

Source from the content-addressed store, hash-verified

174
175@cross_language_test
176def test_serialization_without_schema(data_file_path, schema=None):
177 schema = schema or create_foo_schema()
178 encoder = pyfory.create_row_encoder(schema)
179 foo = create_foo()
180 with open(data_file_path, "rb+") as f:
181 data_bytes = f.read()
182 buf = pyfory.Buffer(data_bytes, 0, len(data_bytes))
183 row = pyfory.RowData(schema, buf)
184 debug_print("row", row)
185 obj = encoder.from_row(row)
186 debug_print("deserialized foo", obj)
187 assert str(foo.f5) == str(obj.f5)
188 # class of `f5` is generated, which may be different from class
189 # of deserialized `f5`
190 f5 = foo.f5
191 foo.f5 = None
192 obj.f5 = None
193 # compare data using str instead of object to workaround different
194 # class name
195 assert str(obj) == str(foo)
196 f.seek(0)
197 f.truncate()
198 foo.f5 = f5
199 row = encoder.to_row(foo)
200 f.write(row.to_bytes())
201
202
203@cross_language_test

Callers 1

Calls 9

create_foo_schemaFunction · 0.85
from_rowMethod · 0.80
create_fooFunction · 0.70
debug_printFunction · 0.70
readMethod · 0.65
writeMethod · 0.65
BufferMethod · 0.45
to_rowMethod · 0.45
to_bytesMethod · 0.45

Tested by

no test coverage detected