How to wait for service_executed before doing assert

I’m trying to write a test for a component. Unfortunately my assert line is being executed before my change has been executed (and therefore fails).

How can I put a delay after calling a service so that test-hass has enough time to execute my call and change the state of an entity?

I tried hass.block_till_done() but this simple blocks and eventually gets killed because of the timeout (even with higher timeouts for tox it gets killed). Any ideas?

Thanks in advance!

hass.block_till_done should work. It will wait all pending tasks completed. Maybe you have some tasks indeed are doing some I/O blocking operation.

I’m working on mocks so there shouldn’t be any IO going on. For some reason it just blocks and gets killed.