Skip to content

Commit

Permalink
Lower expected accuracy for dummy tests with conversions
Browse files Browse the repository at this point in the history
This makes them more robust against these unnecessary CI failures:

`assert 76.9995346069336 == 77.0 ± 7.7e-05`
  • Loading branch information
stefanscherzinger committed Aug 26, 2024
1 parent 867751c commit 2355856
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions schunk_egu_egk_gripper_dummy/tests/test_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def test_dummy_moves_to_absolute_position():
}

dummy.post(command)
assert dummy.get_actual_position() == pytest.approx(target_pos / 1000.0)
assert dummy.get_actual_position() == pytest.approx(
target_pos / 1000.0, rel=1e-3
)
assert dummy.get_status_bit(bit=13) == 1 # position reached
assert dummy.get_status_bit(bit=4) == 1 # command successfully processed

Expand All @@ -97,7 +99,7 @@ def test_dummy_moves_to_relative_position():
dummy.post(command)
after = dummy.get_actual_position()
assert after < before # we are decreasing
assert after == pytest.approx(before + target_pos / 1000.0)
assert after == pytest.approx(before + target_pos / 1000.0, rel=1e-3)
assert dummy.get_status_bit(bit=13) == 1 # position reached
assert dummy.get_status_bit(bit=4) == 1 # command successfully processed

Expand Down
4 changes: 2 additions & 2 deletions schunk_egu_egk_gripper_dummy/tests/test_plc_communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ def test_dummy_supports_reading_target_position():
dummy = Dummy()
target_pos = 12300 # um
dummy.plc_output_buffer[4:8] = bytes(struct.pack("i", target_pos))
assert pytest.approx(dummy.get_target_position()) == target_pos / 1000.0
assert pytest.approx(dummy.get_target_position(), rel=1e-3) == target_pos / 1000.0


def test_dummy_supports_reading_target_speed():
dummy = Dummy()
target_speed = 55300
dummy.plc_output_buffer[8:12] = bytes(struct.pack("i", target_speed))
assert pytest.approx(dummy.get_target_speed()) == target_speed / 1000.0
assert pytest.approx(dummy.get_target_speed(), rel=1e-3) == target_speed / 1000.0


def test_dummy_supports_writing_actual_position():
Expand Down

0 comments on commit 2355856

Please sign in to comment.