From e11a8b4c613be10760a3d7780473ba7dd56cef74 Mon Sep 17 00:00:00 2001 From: Danilo Lessa Bernardineli Date: Thu, 21 Dec 2023 11:09:47 -0300 Subject: [PATCH] parametrize test_runs --- testing/test_runs.py | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/testing/test_runs.py b/testing/test_runs.py index 60ded2ba..46962b1e 100644 --- a/testing/test_runs.py +++ b/testing/test_runs.py @@ -158,42 +158,25 @@ def sweeped(params: Parameters, substep: Substep, history: StateHistory, state: ) return exp - -def test_mc_sweep_experiment(): - experiment_assertions(create_experiment( - N_RUNS=2, N_TIMESTEPS=2, params=SWEEP_PARAMS), ExecutionMode.local_mode) - experiment_assertions(create_experiment( - N_RUNS=2, N_TIMESTEPS=2, params=SWEEP_PARAMS), ExecutionMode.single_mode) +@pytest.mark.parametrize("mode", ["local_proc", "single_proc", "multi_proc"]) +def test_mc_sweep_experiment(mode): experiment_assertions(create_experiment( - N_RUNS=2, N_TIMESTEPS=2, params=SWEEP_PARAMS), ExecutionMode.multi_mode) + N_RUNS=2, N_TIMESTEPS=2, params=SWEEP_PARAMS), mode) - -def test_unique_sweep_experiment(): - experiment_assertions(create_experiment( - N_RUNS=1, N_TIMESTEPS=2, params=SWEEP_PARAMS), ExecutionMode.local_mode) - experiment_assertions(create_experiment( - N_RUNS=1, N_TIMESTEPS=2, params=SWEEP_PARAMS), ExecutionMode.single_mode) +@pytest.mark.parametrize("mode", ["local_proc", "single_proc", "multi_proc"]) +def test_unique_sweep_experiment(mode): experiment_assertions(create_experiment( - N_RUNS=1, N_TIMESTEPS=2, params=SWEEP_PARAMS), ExecutionMode.multi_mode) + N_RUNS=1, N_TIMESTEPS=2, params=SWEEP_PARAMS), mode) - -def test_mc_single_experiment(): - experiment_assertions(create_experiment( - N_RUNS=2, N_TIMESTEPS=2, params=SINGLE_PARAMS), ExecutionMode.local_mode) - experiment_assertions(create_experiment( - N_RUNS=2, N_TIMESTEPS=2, params=SINGLE_PARAMS), ExecutionMode.single_mode) +@pytest.mark.parametrize("mode", ["local_proc", "single_proc", "multi_proc"]) +def test_mc_single_experiment(mode): experiment_assertions(create_experiment( - N_RUNS=2, N_TIMESTEPS=2, params=SINGLE_PARAMS), ExecutionMode.multi_mode) + N_RUNS=2, N_TIMESTEPS=2, params=SINGLE_PARAMS), mode) - -def test_unique_single_experiment(): - experiment_assertions(create_experiment( - N_RUNS=1, N_TIMESTEPS=2, params=SINGLE_PARAMS), ExecutionMode.local_mode) +@pytest.mark.parametrize("mode", ["local_proc", "single_proc", "multi_proc"]) +def test_unique_single_experiment(mode): experiment_assertions(create_experiment( - N_RUNS=1, N_TIMESTEPS=2, params=SINGLE_PARAMS), ExecutionMode.single_mode) - with pytest.raises(ValueError) as e_info: - experiment_assertions(create_experiment( - N_RUNS=1, N_TIMESTEPS=2, params=SINGLE_PARAMS), ExecutionMode.multi_mode) + N_RUNS=1, N_TIMESTEPS=2, params=SINGLE_PARAMS), mode) def experiment_assertions(exp, mode=None):