Port tests to `Portal.run_from_ns()`

func_refs_always
Tyler Goodlet 2020-12-22 10:26:58 -05:00
parent 9fd3c42eb1
commit 493f2efb50
2 changed files with 7 additions and 4 deletions

View File

@ -124,12 +124,15 @@ async def spawn_and_check_registry(
assert not actor.is_arbiter
async with tractor.get_arbiter(*arb_addr) as portal:
if actor.is_arbiter:
async def get_reg():
return actor._registry
extra = 1 # arbiter is local root actor
else:
get_reg = partial(portal.run, 'self', 'get_registry')
get_reg = partial(portal.run_from_ns, 'self', 'get_registry')
extra = 2 # local root actor + remote arbiter
# ensure current actor is registered
@ -254,7 +257,7 @@ async def close_chans_before_nursery(
async with tractor.get_arbiter(*arb_addr) as aportal:
try:
get_reg = partial(aportal.run, 'self', 'get_registry')
get_reg = partial(aportal.run_from_ns, 'self', 'get_registry')
async with tractor.open_nursery() as tn:
portal1 = await tn.run_in_actor(
@ -264,7 +267,7 @@ async def close_chans_before_nursery(
agen1 = await portal1.result()
portal2 = await tn.start_actor('consumer2', rpc_module_paths=[__name__])
agen2 = await portal2.run(__name__, 'stream_forever')
agen2 = await portal2.run(stream_forever)
async with trio.open_nursery() as n:
n.start_soon(streamer, agen1)

View File

@ -46,7 +46,7 @@ async def test_self_is_registered_localportal(arb_addr):
assert actor.is_arbiter
async with tractor.get_arbiter(*arb_addr) as portal:
assert isinstance(portal, tractor._portal.LocalPortal)
sockaddr = await portal.run('self', 'wait_for_actor', name='arbiter')
sockaddr = await portal.run_from_ns('self', 'wait_for_actor', name='arbiter')
assert sockaddr[0] == arb_addr