Commit 4993acd1 authored by Jibril Mammeri's avatar Jibril Mammeri
Browse files

Improve message when hard limit is reached

parent 996e88ef
Pipeline #35415 failed with stages
in 85 minutes and 4 seconds
...@@ -1911,7 +1911,9 @@ class Axis: ...@@ -1911,7 +1911,9 @@ class Axis:
self._update_settings(state) self._update_settings(state)
if not state.MOVING: if not state.MOVING:
if limit_error and (state.LIMPOS or state.LIMNEG): if limit_error and (state.LIMPOS or state.LIMNEG):
raise AxisOnLimitError(str(state)) raise AxisOnLimitError(
f"{self.name}: {str(state)} at {self.position}"
)
elif state.FAULT: elif state.FAULT:
raise AxisFaultError(str(state)) raise AxisFaultError(str(state))
return state return state
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# Distributed under the GNU LGPLv3. See LICENSE for more info. # Distributed under the GNU LGPLv3. See LICENSE for more info.
import pytest import pytest
from unittest import mock
from bliss.common.axis import AxisState, AxisOnLimitError
def test_axis_stdout(roby, capsys, log_shell_mode): def test_axis_stdout(roby, capsys, log_shell_mode):
...@@ -47,3 +49,16 @@ def test_axis_stdout2(roby, bad_motor, capsys, log_shell_mode): ...@@ -47,3 +49,16 @@ def test_axis_stdout2(roby, bad_motor, capsys, log_shell_mode):
out, err = capsys.readouterr() out, err = capsys.readouterr()
assert "Axis roby stopped at position" in out assert "Axis roby stopped at position" in out
def test_axis_stderr1(roby):
with mock.patch.object(roby.controller, "state") as new_state:
new_state.return_value = AxisState("READY", "LIMNEG")
assert roby.state.LIMNEG
with pytest.raises(
AxisOnLimitError,
match=r"roby: READY \(Axis is READY\) \| "
r"LIMNEG \(Hardware low limit active\) at [0-9\.]*",
):
roby.jog()
roby.stop()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment