MCPcopy
hub / github.com/faust-streaming/faust / test_paramters_with_custom_init

Function test_paramters_with_custom_init

tests/functional/test_models.py:95–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93
94
95def 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
117def test_parameters_with_custom_init_and_super():

Callers

nothing calls this directly

Calls 4

PointClass · 0.70
dumpsMethod · 0.45
loadsMethod · 0.45
from_dataMethod · 0.45

Tested by

no test coverage detected