-
Notifications
You must be signed in to change notification settings - Fork 23
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
Make put_mock
an AsyncMock
#539
Milestone
Comments
Adding an example from the PMAC device which has this issue: @AsyncStatus.wrap
async def set(self, value: int, wait=True, timeout=None):
prog_str = f"&2b{value}r"
assert isinstance(timeout, SupportsFloat) or (
timeout is None
), f"ProgramRunner does not support calculating timeout itself, {timeout}"
await self.signal.set(prog_str, wait=wait)
# First wait for signal to go to 1, then wait for the scan to finish.
await wait_for_value(
self.status,
ScanState.RUNNING,
timeout=DEFAULT_TIMEOUT,
)
await wait_for_value(self.status, ScanState.DONE, timeout) In the test, async def go_high_then_low():
set_mock_value(fake_pmac.scanstatus, 1)
await asyncio.sleep(0.01)
set_mock_value(fake_pmac.scanstatus, 0)
prog_num = 10
callback_on_mock_put(
fake_pmac.pmac_string,
lambda *args, **kwargs: asyncio.create_task(go_high_then_low()), # type: ignore
) |
Would someone from MX like to work on this? Or should we put it on our backlog? |
If you're happy for us to do it we can, I think it's like a one line change. |
Yes please |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As a developer I was expecting to be able to do the following:
However, because
put_mock
is aMock
not anAsyncMock
I cannot. Instead I have had to go around the mock and do:The text was updated successfully, but these errors were encountered: