File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -173,3 +173,29 @@ def control_func():
173173
174174 control_indexes = [run_experiment () for i in range (5 )]
175175 assert set (control_indexes ) == set ([0 ])
176+
177+
178+ @pytest .mark .parametrize ('randomize' , [True , False ])
179+ def test_candidates_first_executes_control_last (randomize ):
180+ num_candidates = 100
181+
182+ def run_experiment ():
183+ exp = laboratory .Experiment ()
184+
185+ counter = {'index' : 0 }
186+ def increment_counter ():
187+ counter ['index' ] += 1
188+
189+ def control_func ():
190+ return counter ['index' ]
191+
192+ cand_func = mock .Mock (side_effect = increment_counter )
193+
194+ exp .control (control_func )
195+ for _ in range (num_candidates ):
196+ exp .candidate (cand_func )
197+
198+ return exp .conduct (randomize = randomize , candidates_first = True )
199+
200+ control_indexes = [run_experiment () for i in range (5 )]
201+ assert set (control_indexes ) == {num_candidates }
You can’t perform that action at this time.
0 commit comments