Skip to content

Commit 150ba2c

Browse files
committed
Add timeout to _recv_reports_until()
This avoid tests hanging forever if for some reason the expected report never comes, which can happen when there are bugs or the tests are incorrect. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 3d34cb8 commit 150ba2c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tests/timeseries/_ev_charger_pool/test_ev_charger_pool_control_methods.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,13 @@ async def _recv_reports_until(
156156
"""Receive reports until the given condition is met."""
157157
max_reports = 10
158158
ctr = 0
159-
latest_report: EVChargerPoolReport | None = None
160159
while ctr < max_reports:
161160
ctr += 1
162-
latest_report = await bounds_rx.receive()
163-
if check(latest_report):
164-
break
165-
166-
return latest_report
161+
async with asyncio.timeout(10.0):
162+
report = await bounds_rx.receive()
163+
if check(report):
164+
return report
165+
return None
167166

168167
def _assert_report( # pylint: disable=too-many-arguments
169168
self,

0 commit comments

Comments
 (0)