From 6cc5333cfa2722d34504d0643aec5dbe925bd496 Mon Sep 17 00:00:00 2001 From: niksirbi Date: Mon, 4 Nov 2024 09:09:38 +0100 Subject: [PATCH] refactored parameters for test across time ranges --- tests/test_unit/test_kinematics.py | 36 +++++++++--------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/tests/test_unit/test_kinematics.py b/tests/test_unit/test_kinematics.py index 8fe7a147..0c6207ac 100644 --- a/tests/test_unit/test_kinematics.py +++ b/tests/test_unit/test_kinematics.py @@ -204,6 +204,12 @@ def test_approximate_derivative_with_invalid_order(order): kinematics.compute_time_derivative(data, order=order) +time_points_value_error = pytest.raises( + ValueError, + match="At least 2 time points are required to compute path length", +) + + @pytest.mark.parametrize( "start, stop, expected_exception", [ @@ -217,33 +223,11 @@ def test_approximate_derivative_with_invalid_order(order): (1, 8, does_not_raise()), (1.5, 8.5, does_not_raise()), (2, None, does_not_raise()), - # Empty time range (because start > stop) - ( - 9, - 0, - pytest.raises( - ValueError, - match="At least 2 time points", - ), - ), - # Empty time range (because of invalid start type) - ( - "text", - 9, - pytest.raises( - ValueError, - match="At least 2 time points", - ), - ), + # Empty time ranges + (9, 0, time_points_value_error), # start > stop + ("text", 9, time_points_value_error), # invalid start type # Time range too short - ( - 0, - 0.5, - pytest.raises( - ValueError, - match="At least 2 time points", - ), - ), + (0, 0.5, time_points_value_error), ], ) def test_path_length_across_time_ranges(