Standalone test for classmethod serialization - reproduces the original error.
()
| 195 | |
| 196 | |
| 197 | def test_classmethod_serialization(): |
| 198 | """Standalone test for classmethod serialization - reproduces the original error.""" |
| 199 | fory = pyfory.Fory(xlang=False, strict=False, ref=True, compatible=False) |
| 200 | |
| 201 | class A: |
| 202 | @classmethod |
| 203 | def f(cls): |
| 204 | pass |
| 205 | |
| 206 | @staticmethod |
| 207 | def g(): |
| 208 | return A |
| 209 | |
| 210 | method = A.f |
| 211 | serialized = fory.serialize(method) |
| 212 | deserialized = fory.deserialize(serialized) |
| 213 | |
| 214 | assert isinstance(deserialized, type(method)) |
| 215 | # Check that the class names are the same (the classes might be different instances due to deserialization) |
| 216 | assert deserialized.__self__.__name__ == method.__self__.__name__ |
| 217 | assert deserialized.__func__.__name__ == method.__func__.__name__ |
| 218 | |
| 219 | # Most importantly, check that the deserialized method is callable and has the same behavior |
| 220 | # Both should return None for this test case |
| 221 | original_result = method() |
| 222 | deserialized_result = deserialized() |
| 223 | assert original_result == deserialized_result |
| 224 | |
| 225 | |
| 226 | def test_staticmethod_serialization(): |
nothing calls this directly
no test coverage detected