(data_file_path, schema=None)
| 174 | |
| 175 | @cross_language_test |
| 176 | def 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 |
no test coverage detected