@@ -61,6 +61,12 @@ class SessionContext:
6161 """The RobotCommunication instance, only set for field tests"""
6262 estop_mode : Optional [Any ] = None
6363 """The EstopMode, only set for field tests"""
64+ simulator : Optional [Any ] = None
65+ """The Simulator context manager, only set for simulated tests"""
66+ blue_full_system : Optional [Any ] = None
67+ """The blue FullSystem context manager, only set for simulated tests"""
68+ yellow_full_system : Optional [Any ] = None
69+ """The yellow FullSystem context manager, only set for simulated tests"""
6470
6571
6672@pytest .fixture
@@ -108,6 +114,13 @@ def bound_runner(session):
108114 owns_thunderscope = False ,
109115 )
110116 else :
117+ # Relaunch the simulator and full systems so each test starts from clean state.
118+ # The ProtoUnixIOs reconnect automatically.
119+ context .simulator .restart ()
120+ context .blue_full_system .restart ()
121+ context .yellow_full_system .restart ()
122+ time .sleep (LAUNCH_DELAY_S )
123+
111124 runner = SimulatedTestRunner (
112125 test_name ,
113126 session .thunderscope ,
@@ -178,7 +191,6 @@ def simulated_session(args, runtime_subpath):
178191 gamecontroller .setup_proto_unix_io (
179192 blue_full_system_proto_unix_io = blue_full_system_proto_unix_io ,
180193 yellow_full_system_proto_unix_io = yellow_full_system_proto_unix_io ,
181- simulator_proto_unix_io = simulator_proto_unix_io ,
182194 )
183195
184196 time .sleep (LAUNCH_DELAY_S )
@@ -188,6 +200,9 @@ def simulated_session(args, runtime_subpath):
188200 yellow_full_system_proto_unix_io = yellow_full_system_proto_unix_io ,
189201 simulator_proto_unix_io = simulator_proto_unix_io ,
190202 gamecontroller = gamecontroller ,
203+ simulator = simulator ,
204+ blue_full_system = blue_fs ,
205+ yellow_full_system = yellow_fs ,
191206 )
192207
193208
0 commit comments