Skip to content

Commit b9e16ad

Browse files
committed
test: add explicit coverage for _InvokeSession async send_to_parent
Ensures the `isawaitable` branch in `_InvokeSession.send_to_parent` is covered when the parent machine uses an async engine, fixing a coverage drop detected by Codecov.
1 parent e7e44a2 commit b9e16ad

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/test_scxml_units.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,21 @@ def run(self, ctx):
10311031
assert wrapper._instance is handler_instance
10321032

10331033

1034+
class TestInvokeSessionSendToParentAsync:
1035+
async def test_send_to_parent_awaitable(self):
1036+
"""send_to_parent calls ensure_future when parent.send returns an awaitable."""
1037+
from statemachine.io.scxml.invoke import _InvokeSession
1038+
1039+
async def async_send(event, **kwargs):
1040+
pass
1041+
1042+
parent = Mock()
1043+
parent.send = async_send
1044+
session = _InvokeSession(parent, invokeid="inv1")
1045+
# Should not raise — the coroutine is scheduled via ensure_future
1046+
session.send_to_parent("child.done", key="value")
1047+
1048+
10341049
class TestOrderedSetStr:
10351050
def test_str_representation(self):
10361051
"""OrderedSet.__str__ returns a set-like string."""

0 commit comments

Comments
 (0)