admin管理员组文章数量:1122832
I'm testing asynchronous code using PyTest.
Can't find any existing libraries that provide simple function like "Await until" or "Polling":
operation.run_in_background()
await_until(lambda: operation.is_ready(), interval=1, timeout=10)
It's easy to implement such function, but I believe there is a ready library for this.
Thank you.
I'm testing asynchronous code using PyTest.
Can't find any existing libraries that provide simple function like "Await until" or "Polling":
operation.run_in_background()
await_until(lambda: operation.is_ready(), interval=1, timeout=10)
It's easy to implement such function, but I believe there is a ready library for this.
Thank you.
Share Improve this question edited yesterday Aleks Ya asked yesterday Aleks YaAleks Ya 9095 gold badges15 silver badges32 bronze badges1 Answer
Reset to default 0polling might be a good fit for you.
operation.run_in_background()
timeout_s = 10
interval_s = 1
try:
polling.poll(
lambda: operation.is_ready(),
timeout=timeout_s,
step=interval_s
)
except polling.TimeoutException:
pytest.fail(f"Operation could not be completed within {timeout_s}s.")
本文标签: pythonWaitUntil strategy in PyTestStack Overflow
版权声明:本文标题:python - Wait-Until strategy in PyTest - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736281254a1926261.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论