pandalee99 commented on code in PR #2335:
URL: https://github.com/apache/fory/pull/2335#discussion_r2144597885


##########
python/pyfory/tests/test_cross_language.py:
##########
@@ -466,6 +466,35 @@ def test_serialize_simple_struct(data_file_path):
     struct_round_back(data_file_path, fory, obj)
 
 
+class SomeClass:
+    f1: "SomeClass"
+    f2: Dict[str, str]
+    f3: Dict[str, str]
+
+
+def test_custom_class_roundtrip():
+    fory = pyfory.Fory(ref_tracking=True)
+    fory.register_type(SomeClass, typename="example.SomeClass")
+    obj1 = SomeClass()
+    obj1.f2 = {"k1": "v1", "k2": "v2"}
+    obj1.f1, obj1.f3 = obj1, obj1.f2
+    data1 = fory.serialize(obj1)
+    obj2 = fory.deserialize(data1)
+    data2 = fory.serialize(obj2)
+    assert data1 == data2
+    # bytes can be data serialized by other languages.
+    # due to the self-referential nature of this object,
+    # direct `==` comparison will fail.
+    # 1. Serialize `obj1` to `data1`
+    # 2. Deserialize `data1` to `obj2`
+    # 3. Serialize `obj2` to `data2`
+    # If `data1 == data2`, the round-trip preserves value equivalence.
+    # print(data1)
+    # print(data2)

Review Comment:
   Maybe it's not very reasonable to use `print`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to