Directly call DummyStage instance during movement test for speed
This commit is contained in:
parent
bc103f8cdf
commit
90dbb35a9e
2 changed files with 46 additions and 12 deletions
19
tests/mock_things/mock_cancel.py
Normal file
19
tests/mock_things/mock_cancel.py
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue