Skip to content

Commit 78c6b52

Browse files
committed
test: cover EventQueue.reject_futures with future=None items
1 parent a8c8d97 commit 78c6b52

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/test_async_futures.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import asyncio
1111

1212
import pytest
13+
from statemachine.engines.base import EventQueue
14+
from statemachine.event_data import TriggerData
1315

1416
from statemachine import State
1517
from statemachine import StateChart
@@ -320,3 +322,20 @@ async def fn2():
320322
assert results["fn1"] == "noop ok"
321323
assert "fn2" in errors
322324
assert str(errors["fn2"]) == "noop2 is not allowed"
325+
326+
327+
class TestEventQueueRejectFutures:
328+
"""Unit tests for EventQueue.reject_futures."""
329+
330+
def test_reject_futures_skips_items_without_future(self):
331+
"""Items with future=None are silently skipped."""
332+
sm = TrafficLight()
333+
334+
queue = EventQueue()
335+
td = TriggerData(machine=sm, event=None)
336+
assert td.future is None
337+
queue.put(td)
338+
339+
queue.reject_futures(RuntimeError("boom"))
340+
# No exception raised, item still in queue
341+
assert not queue.is_empty()

0 commit comments

Comments
 (0)