From a99a4c93535ccbe138715a3c1b2003e70bbfc278 Mon Sep 17 00:00:00 2001 From: goodboy Date: Tue, 25 Aug 2026 00:09:10 -0400 Subject: [PATCH] Assert `to_actor.run()` runtime lifecycle The implicit-runtime test verified the caller started outside Tractor but did not prove that the target ran inside an actor or that the private runtime was gone when the call returned. Assert an active actor inside the shared remote target and assert the caller has no current actor again after the one-shot call completes. Review: PR #481 (goodboy) https://github.com/goodboy/tractor/pull/481#pullrequestreview-5012942328 (this patch was generated in some part by `opencode` using `gpt-5.6-sol` (`openai`)) --- tests/test_to_actor.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_to_actor.py b/tests/test_to_actor.py index 599d6dbf..52967e08 100644 --- a/tests/test_to_actor.py +++ b/tests/test_to_actor.py @@ -33,6 +33,13 @@ from ._helpers import ( async def add_one( n: int, ) -> int: + ''' + Increment within an active actor runtime. + + ''' + assert tractor.current_actor( + err_on_no_runtime=False, + ) is not None return n + 1 @@ -125,7 +132,9 @@ def test_one_shot_boots_implicit_runtime( ''' Outside any actor-runtime `to_actor.run()` boots one implicitly (just like bare `open_nursery()` usage) - configured via pass-through `runtime_kwargs`. + configured via pass-through `runtime_kwargs`. The remote target + asserts its runtime exists; the caller then verifies the private + runtime is fully torn down before `to_actor.run()` returns. ''' async def main() -> None: @@ -142,6 +151,9 @@ def test_one_shot_boots_implicit_runtime( ), ) assert result == 42 + assert tractor.current_actor( + err_on_no_runtime=False, + ) is None trio.run(main)