()
| 93 | |
| 94 | |
| 95 | def test_paramters_with_custom_init(): |
| 96 | class Point(Record, include_metadata=False): |
| 97 | x: int |
| 98 | y: int |
| 99 | |
| 100 | def __init__(self, x, y, **kwargs): |
| 101 | self.x = x |
| 102 | self.y = y |
| 103 | |
| 104 | p = Point(30, 10) |
| 105 | assert p.x == 30 |
| 106 | assert p.y == 10 |
| 107 | |
| 108 | payload = p.dumps(serializer="json") |
| 109 | assert payload == b'{"x":30,"y":10}' |
| 110 | |
| 111 | data = json.loads(payload) |
| 112 | p2 = Point.from_data(data) |
| 113 | assert p2.x == 30 |
| 114 | assert p2.y == 10 |
| 115 | |
| 116 | |
| 117 | def test_parameters_with_custom_init_and_super(): |