From cfb74e588d1dc131f58ead74ebae7b716b2d046f Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 19 Oct 2023 11:17:07 -0400 Subject: [PATCH] Get remaining suites passing.. ..by ensuring `reg_addr` fixture value passthrough to subactor eps --- tests/test_debugger.py | 4 ++-- tests/test_docs_examples.py | 2 +- tests/test_rpc.py | 32 +++++++++++++++++++++++++++----- tests/test_spawning.py | 7 ++++--- 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/tests/test_debugger.py b/tests/test_debugger.py index 923aa94d..3fcf71f9 100644 --- a/tests/test_debugger.py +++ b/tests/test_debugger.py @@ -203,7 +203,7 @@ def ctlc( # XXX: disable pygments highlighting for auto-tests # since some envs (like actions CI) will struggle # the the added color-char encoding.. - from tractor._debug import TractorConfig + from tractor.devx._debug import TractorConfig TractorConfig.use_pygements = False yield use_ctlc @@ -685,7 +685,7 @@ def test_multi_daemon_subactors( # now the root actor won't clobber the bp_forever child # during it's first access to the debug lock, but will instead # wait for the lock to release, by the edge triggered - # ``_debug.Lock.no_remote_has_tty`` event before sending cancel messages + # ``devx._debug.Lock.no_remote_has_tty`` event before sending cancel messages # (via portals) to its underlings B) # at some point here there should have been some warning msg from diff --git a/tests/test_docs_examples.py b/tests/test_docs_examples.py index 7a923343..63ad07a2 100644 --- a/tests/test_docs_examples.py +++ b/tests/test_docs_examples.py @@ -20,7 +20,7 @@ from tractor._testing import ( def run_example_in_subproc( loglevel: str, testdir, - arb_addr: tuple[str, int], + reg_addr: tuple[str, int], ): @contextmanager diff --git a/tests/test_rpc.py b/tests/test_rpc.py index 71f3258b..a18bcb02 100644 --- a/tests/test_rpc.py +++ b/tests/test_rpc.py @@ -15,9 +15,19 @@ async def sleep_back_actor( func_name, func_defined, exposed_mods, + *, + reg_addr: tuple, ): if actor_name: - async with tractor.find_actor(actor_name) as portal: + async with tractor.find_actor( + actor_name, + # NOTE: must be set manually since + # the subactor doesn't have the reg_addr + # fixture code run in it! + # TODO: maybe we should just set this once in the + # _state mod and derive to all children? + registry_addrs=[reg_addr], + ) as portal: try: await portal.run(__name__, func_name) except tractor.RemoteActorError as err: @@ -52,11 +62,17 @@ async def short_sleep(): 'fail_on_syntax', ], ) -def test_rpc_errors(reg_addr, to_call, testdir): - """Test errors when making various RPC requests to an actor +def test_rpc_errors( + reg_addr, + to_call, + testdir, +): + ''' + Test errors when making various RPC requests to an actor that either doesn't have the requested module exposed or doesn't define the named function. - """ + + ''' exposed_mods, funcname, inside_err = to_call subactor_exposed_mods = [] func_defined = globals().get(funcname, False) @@ -84,8 +100,13 @@ def test_rpc_errors(reg_addr, to_call, testdir): # spawn a subactor which calls us back async with tractor.open_nursery( - arbiter_addr=reg_addr, + registry_addrs=[reg_addr], enable_modules=exposed_mods.copy(), + + # NOTE: will halt test in REPL if uncommented, so only + # do that if actually debugging subactor but keep it + # disabled for the test. + # debug_mode=True, ) as n: actor = tractor.current_actor() @@ -102,6 +123,7 @@ def test_rpc_errors(reg_addr, to_call, testdir): exposed_mods=exposed_mods, func_defined=True if func_defined else False, enable_modules=subactor_exposed_mods, + reg_addr=reg_addr, ) def run(): diff --git a/tests/test_spawning.py b/tests/test_spawning.py index 6a4b2988..5995ed2d 100644 --- a/tests/test_spawning.py +++ b/tests/test_spawning.py @@ -32,8 +32,7 @@ async def spawn( if actor.is_arbiter: - async with tractor.open_nursery( - ) as nursery: + async with tractor.open_nursery() as nursery: # forks here portal = await nursery.run_in_actor( @@ -55,7 +54,9 @@ async def spawn( return 10 -def test_local_arbiter_subactor_global_state(reg_addr): +def test_local_arbiter_subactor_global_state( + reg_addr, +): result = trio.run( spawn, True,