File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 33import asyncio
44import contextlib
55import json
6+ import logging
67import sys
78from datetime import datetime , timezone
89from 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+
114130async def test_actor_fails_cleanly_context_manager () -> None :
115131 async with Actor () as actor :
116132 assert actor ._is_initialized
You can’t perform that action at this time.
0 commit comments