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

Function test_map_encoder

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

Source from the content-addressed store, hash-verified

141
142@cross_language_test
143def test_map_encoder(data_file_path):
144 encoder = pyfory.encoder(A)
145 a = A(f1=1, f2={"pid": "12345", "ip": "0.0.0.0", "k1": "v1"})
146 with open(data_file_path, "rb+") as f:
147 data_bytes = f.read()
148 obj = encoder.decode(data_bytes)
149 debug_print("deserialized obj", obj)
150 # Compare by dict since decoder returns a record class, not the original class
151 assert to_dict(obj) == to_dict(a)
152 decoded_round_trip = encoder.decode(encoder.encode(a))
153 assert to_dict(decoded_round_trip) == to_dict(a)
154 f.seek(0)
155 f.truncate()
156 f.write(encoder.encode(a))
157
158
159@cross_language_test

Callers

nothing calls this directly

Calls 7

to_dictFunction · 0.85
AClass · 0.70
debug_printFunction · 0.70
readMethod · 0.65
decodeMethod · 0.65
encodeMethod · 0.65
writeMethod · 0.65

Tested by

no test coverage detected