Skip to content

Commit

Permalink
Rename compute_time_derivative test + parametrise expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
lochhh committed Jan 30, 2025
1 parent 37cecae commit 8bd6ef1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/test_unit/test_kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,19 @@ def test_kinematics_with_invalid_dataset(
getattr(kinematics, f"compute_{kinematic_variable}")(position)


@pytest.mark.parametrize("order", [0, -1, 1.0, "1"])
def test_approximate_derivative_with_invalid_order(order):
@pytest.mark.parametrize(
"order, expected_exception",
[
(0, pytest.raises(ValueError)),
(-1, pytest.raises(ValueError)),
(1.0, pytest.raises(TypeError)),
("1", pytest.raises(TypeError)),
],
)
def test_time_derivative_with_invalid_order(order, expected_exception):
"""Test that an error is raised when the order is non-positive."""
data = np.arange(10)
expected_exception = ValueError if isinstance(order, int) else TypeError
with pytest.raises(expected_exception):
with expected_exception:
kinematics.compute_time_derivative(data, order=order)


Expand Down

0 comments on commit 8bd6ef1

Please sign in to comment.