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 3
3
import asyncio
4
4
import contextlib
5
5
import json
6
+ import logging
6
7
import sys
7
8
from datetime import datetime , timezone
8
9
from typing import TYPE_CHECKING , Any , cast
@@ -111,6 +112,21 @@ async def test_actor_fails_cleanly_init_fail() -> None:
111
112
assert actor ._is_initialized is False
112
113
113
114
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
+
114
130
async def test_actor_fails_cleanly_context_manager () -> None :
115
131
async with Actor () as actor :
116
132
assert actor ._is_initialized
You can’t perform that action at this time.
0 commit comments