-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a NoOpStatus #521
Comments
Can you provide a use case please? The closest we have at the moment is: @AsyncStatus.wrap
async def kickoff(self) -> None:
pass Which could be (slightly) reduce if we had a NoOpStatus: def kickoff(self) -> Status:
return NoOpStatus() |
It's more for downstream testing e.g. class MyDevice(Device):
def set(self, value):
# Some long running thing that checks against PVs etc
def test_my_plan():
my_device.set = MagicMock(return_value=NullStatus())
my_plan(my_device) In this case the logic in set is too complicated for the mocked object (via |
Would it have to be a subclass of E.g. @AsyncStatus.wrap
async def completed_status(exception: Optional[Exception] = None) -> None:
if exception:
raise exception
def test_my_plan():
my_device.set = MagicMock(return_value=completed_status())
my_plan(my_device) |
Yh, that works, I'm not fussed about the implementation, just the behaviour. |
I can pick this up. @DominicOram what did you mean by having an identifier? Won't it be obvious from whatever test is failing? |
It was a request by @dperl-dls. What we've seen in the past is issues where status' are hanging around at the end of tests and have not been sufficiently awaited/cancelled. When this happens it's very hard to tell which of the hundreds of tests produced the status. Personally I think in this case it might not be 100% necessary as it shouldn't really be possible to have the noop hanging around for any length of time. |
I think this part may be addressed in https://github.com/bluesky/ophyd-async/pull/538/files# |
In which case with @dperl-dls away in the spirit of keeping things moving I'm happy to drop the requirement of having them named but he's welcome to open a new issue when he's back. |
ophyd
has aNullStatus
(https://github.com/bluesky/ophyd/blob/050b98f34d68bd9577179accfdfca8f635cc0f31/ophyd/sim.py#L51) that immediately returns, this is very useful for testing as it's something you probably want to inject into many devices. We should provide something similar inophyd-async
where it basically just doesAsyncStatus(asyncio.sleep(0.0))
. It will also be nice to be able to:The text was updated successfully, but these errors were encountered: