From f3de0096b56050ee2baf44136aa2226dc7658eb4 Mon Sep 17 00:00:00 2001 From: Thijs Snelleman Date: Fri, 29 Nov 2024 11:46:45 +0100 Subject: [PATCH] Adding in CPU time tests --- tests/test_runner/test_target_algorithm_runner.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_runner/test_target_algorithm_runner.py b/tests/test_runner/test_target_algorithm_runner.py index 724b2aa01..120295589 100644 --- a/tests/test_runner/test_target_algorithm_runner.py +++ b/tests/test_runner/test_target_algorithm_runner.py @@ -127,7 +127,12 @@ def test_serial_runs(make_runner: Callable[..., TargetFunctionRunner]) -> None: _, first_run_value = first _, second_run_value = second assert int(first_run_value.endtime) <= int(second_run_value.starttime) - + # For these examples, runtime must be larger or equal to cputime + assert first_run_value.time >= first_run_value.cpu_time + assert second_run_value.time >= second_run_value.cpu_time + # And cpu time must be near zero because the target function just sleeps + assert first_run_value.cpu_time < 0.001 + assert second_run_value.cpu_time < 0.001 def test_fail(make_runner: Callable[..., TargetFunctionRunner]) -> None: """Test traceback and error end up in the additional info of a failing run"""