Skip to content

Commit ec47280

Browse files
committed
add E2E test
1 parent 837b244 commit ec47280

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/e2e/test_actor_lifecycle.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,34 @@ async def default_handler(context: BasicCrawlingContext) -> None:
110110
run_result = await run_actor(actor)
111111

112112
assert run_result.status == 'SUCCEEDED'
113+
114+
115+
async def test_actor_sequential_contexts(make_actor: MakeActorFunction, run_actor: RunActorFunction) -> None:
116+
"""Test that Actor and Actor() can be used in sequential async context manager blocks."""
117+
118+
async def main() -> None:
119+
async with Actor as actor:
120+
actor._exit_process = False
121+
assert actor._is_initialized is True
122+
123+
# Actor after Actor.
124+
async with Actor as actor:
125+
actor._exit_process = False
126+
assert actor._is_initialized is True
127+
128+
# Actor() after Actor.
129+
async with Actor(exit_process=False) as actor:
130+
assert actor._is_initialized is True
131+
132+
# Actor() after Actor().
133+
async with Actor(exit_process=False) as actor:
134+
assert actor._is_initialized is True
135+
136+
# Actor after Actor().
137+
async with Actor as actor:
138+
assert actor._is_initialized is True
139+
140+
actor = await make_actor(label='actor-sequential-contexts', main_func=main)
141+
run_result = await run_actor(actor)
142+
143+
assert run_result.status == 'SUCCEEDED'

0 commit comments

Comments
 (0)