Directly call DummyStage instance during movement test for speed

This commit is contained in:
Julian Stirling 2025-08-08 09:45:20 +01:00
parent bc103f8cdf
commit 90dbb35a9e
2 changed files with 46 additions and 12 deletions

View file

@ -0,0 +1,19 @@
"""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):
"""Sleep for the input number of seconds."""
time.sleep(time_in_seconds)