diff --git a/tests/mock_things/mock_cancel.py b/tests/mock_things/mock_cancel.py deleted file mode 100644 index 1e9960a7..00000000 --- a/tests/mock_things/mock_cancel.py +++ /dev/null @@ -1,19 +0,0 @@ -"""Create a fake CancelHook used instead of a dependency, it cannot be used to cancel! - -Certain actions require a CancelHook to be supplied if called directly. The only method -we use from the LabThings CancelHook is ``sleep()``. The CanceHook ``sleep()`` works -exactly like ``time.sleep()`` except with raise an ``InvocationCancelledError`` if the -server receives a cancellation request. - -This is just an object with a sleep method. -""" - -import time - - -class MockCancel: - """A class to use when directly calling an action with CancelHook dependency.""" - - def sleep(self, time_in_seconds: float) -> None: - """Sleep for the input number of seconds.""" - time.sleep(time_in_seconds) diff --git a/tests/test_stage.py b/tests/test_stage.py index 2a28698c..22ec73dc 100644 --- a/tests/test_stage.py +++ b/tests/test_stage.py @@ -18,8 +18,6 @@ from openflexure_microscope_server.things.stage import ( ) from openflexure_microscope_server.things.stage.dummy import DummyStage -from .mock_things.mock_cancel import MockCancel - # Keep the size and number of moves fairly small or the tests can take forever point3d = st.tuples( st.integers(min_value=-100, max_value=100), @@ -60,12 +58,7 @@ def test_override_base_movement(): class BadStage1(BaseStage): @lt.action - def move_relative( - self, - cancel: lt.deps.CancelHook, - block_cancellation: bool = False, - **kwargs: int, - ): + def move_relative(self, block_cancellation: bool = False, **kwargs: int): pass with pytest.raises(RedefinedBaseMovementError): @@ -73,12 +66,7 @@ def test_override_base_movement(): class BadStage2(BaseStage): @lt.action - def move_absolute( - self, - cancel: lt.deps.CancelHook, - block_cancellation: bool = False, - **kwargs: int, - ): + def move_absolute(self, block_cancellation: bool = False, **kwargs: int): pass with pytest.raises(RedefinedBaseMovementError): @@ -200,7 +188,6 @@ def _test_move_relative(dummy_stage, axis_inverted, path): :param axis_inverted: Is used to set the inversion. :param path: The 3d path to move over, generated by hypothesis. """ - cancel = MockCancel() dummy_stage.axis_inverted = axis_inverted # Explicitly do axes calculation here to check logic in main code. x_dir = -1 if axis_inverted["x"] else 1 @@ -209,9 +196,7 @@ def _test_move_relative(dummy_stage, axis_inverted, path): position = list(dummy_stage.position.values()) for movement in path: - dummy_stage.move_relative( - cancel=cancel, x=movement[0], y=movement[1], z=movement[2] - ) + dummy_stage.move_relative(x=movement[0], y=movement[1], z=movement[2]) position = [pos + move for pos, move in zip(position, movement, strict=True)] stage_pos = dummy_stage.get_xyz_position() hw_pos = dummy_stage._hardware_position @@ -257,7 +242,6 @@ def _test_move_absolute(dummy_stage, axis_inverted, path): :param axis_inverted: Is used to set the inversion. :param path: The 3d path to move over, generated by hypothesis. """ - cancel = MockCancel() dummy_stage.axis_inverted = axis_inverted # Explicitly do axes calculation here to check logic in main code. x_dir = -1 if axis_inverted["x"] else 1 @@ -265,9 +249,7 @@ def _test_move_absolute(dummy_stage, axis_inverted, path): z_dir = -1 if axis_inverted["z"] else 1 position = list(dummy_stage.position.values()) for move_to in path: - dummy_stage.move_absolute( - cancel=cancel, x=move_to[0], y=move_to[1], z=move_to[2] - ) + dummy_stage.move_absolute(x=move_to[0], y=move_to[1], z=move_to[2]) position = move_to stage_pos = dummy_stage.get_xyz_position() hw_pos = dummy_stage._hardware_position