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

Function test_nested_functions_serialization

python/pyfory/tests/test_function.py:81–106  ·  view source on GitHub ↗

Tests serialization of nested functions.

()

Source from the content-addressed store, hash-verified

79
80
81def test_nested_functions_serialization():
82 """Tests serialization of nested functions."""
83 fory = pyfory.Fory(
84 xlang=False,
85 compatible=False,
86 )
87
88 # Register the necessary types
89 fory.register_type(tuple)
90 fory.register_type(list)
91 # dict is already registered by default with MapSerializer
92
93 def outer_function(x):
94 def inner_function(y):
95 return x + y
96
97 return inner_function
98
99 # Create a nested function
100 nested_func = outer_function(10)
101 fory.register_type(type(nested_func))
102
103 serialized = fory.serialize(nested_func)
104 deserialized = fory.deserialize(serialized)
105
106 assert nested_func(5) == deserialized(5)
107
108
109def test_local_class_serialization():

Callers

nothing calls this directly

Calls 5

register_typeMethod · 0.95
serializeMethod · 0.95
deserializeMethod · 0.95
outer_functionFunction · 0.85
ForyMethod · 0.45

Tested by

no test coverage detected