def test_measure_loop_end(_, mocked_manager, mocked_measure_all_trials, mocked_all_trials_ended): """Tests that measure_loop stops when there is nothing left to measure.""" call_count = 0 def mock_measure_all_trials(*args, **kwargs): # Do the assertions here so that there will be an assert fail on failure # instead of an infinite loop. nonlocal call_count assert call_count == 0 call_count += 1 return False mocked_measure_all_trials.side_effect = mock_measure_all_trials mocked_all_trials_ended.return_value = True measurer.measure_loop('', 0)
def test_measure_loop_loop_until_end(mocked_measure_all_trials, _, __, ___, ____, _____, experiment_config, db_experiment): """Test that measure loop will stop measuring when all trials have ended. In this test, there is more to measure for a few iterations, then the mocked functions will indicate that there is nothing left to measure.""" call_count = 0 # Scheduler is running. loop_iterations = 6 def mock_measure_all_trials(*args, **kwargs): # Do the assertions here so that there will be an assert fail on failure # instead of an infinite loop. nonlocal call_count call_count += 1 if call_count >= loop_iterations: return False return True mocked_measure_all_trials.side_effect = mock_measure_all_trials measurer.measure_loop(experiment_config, 100) assert call_count == loop_iterations
def test_measure_loop_end(_, __, ___, ____, _____, ______, experiment_config, db_experiment): """Tests that measure_loop stops when there is nothing left to measure. In this test, there is nothing left to measure on the first call.""" measurer.measure_loop(experiment_config, 100)