Skip to content

Commit a03b3f1

Browse files
committed
Add test for consideration
1 parent 3dacd65 commit a03b3f1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/unit/actor/test_actor_lifecycle.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
import contextlib
55
import json
6+
import logging
67
import sys
78
from datetime import datetime, timezone
89
from typing import TYPE_CHECKING, Any, cast
@@ -111,6 +112,21 @@ async def test_actor_fails_cleanly_init_fail() -> None:
111112
assert actor._is_initialized is False
112113

113114

115+
async def test_actor_fail_prevents_further_execution(caplog: pytest.LogCaptureFixture) -> None:
116+
caplog.set_level(logging.INFO)
117+
async with Actor:
118+
await Actor.fail(exit_code=2, exception=Exception('abc'), status_message='cde')
119+
raise RuntimeError('This should not trigger')
120+
121+
assert caplog.records[-3].levelno == logging.ERROR # type: ignore[unreachable]
122+
assert caplog.records[-3].msg == 'Actor failed with an exception'
123+
assert caplog.records[-3].exc_text == 'Exception: abc'
124+
assert caplog.records[-2].levelno == logging.INFO
125+
assert caplog.records[-2].msg == 'Exiting Actor'
126+
assert caplog.records[-1].levelno == logging.INFO
127+
assert caplog.records[-1].msg == '[Terminal status message]: cde'
128+
129+
114130
async def test_actor_fails_cleanly_context_manager() -> None:
115131
async with Actor() as actor:
116132
assert actor._is_initialized

0 commit comments

Comments
 (0)