File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717
1818
1919@pytest .fixture
20- def state ():
21- server = Server ()
20+ def server ():
21+ return Server ()
22+
23+ @pytest .fixture
24+ def state (server ):
2225 server .state .ready ()
2326 return server .state
2427
28+ @pytest .fixture
29+ def child_state (server ):
30+ child_server = server .create_child_server (prefix = "child_" )
31+ child_server .state .ready ()
32+ return child_server .state
33+
2534
2635@dataclass
2736class MyData :
@@ -101,6 +110,17 @@ def on_a_change(**_):
101110 mock .assert_called_once_with (53 )
102111
103112
113+ def test_can_handle_child_server (state , child_state ):
114+ typed_state_main = TypedState (state , MyData )
115+ typed_state_child = TypedState (child_state , MyData )
116+
117+ typed_state_main .data .a = 40
118+ typed_state_child .data .a = 3
119+
120+ assert typed_state_main .data .a != typed_state_child .data .a
121+ assert typed_state_child .data .a == state [f"child_{ typed_state_child .name .a } " ]
122+
123+
104124class MyEnum (Enum ):
105125 A = auto ()
106126 B = auto ()
You can’t perform that action at this time.
0 commit comments