Skip to content

Commit 4f2fe34

Browse files
committed
Use timeout to check if a receiver is empty
Checking the length of a receiver is not supported by generic receivers, but only by `Broadcast` receivers. Using a timeout to confirm a channel is empty is the more general approach. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent ab177d0 commit 4f2fe34

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/actor/test_battery_status.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,8 @@ async def test_async_battery_status(self, mocker: MockerFixture) -> None:
713713
)
714714
time.shift(10)
715715
await asyncio.sleep(0.3)
716-
assert len(status_receiver) == 0
716+
with pytest.raises(asyncio.TimeoutError):
717+
await asyncio.wait_for(status_receiver.receive(), timeout=0.1)
717718

718719
await mock_microgrid.mock_client.send(
719720
inverter_data(component_id=INVERTER_ID)

0 commit comments

Comments
 (0)