forked from goodboy/tractor
1
0
Fork 0

Drop run and rpc_module_paths from cancel tests

drop_run
Tyler Goodlet 2021-02-24 14:37:55 -05:00
parent a54260a67e
commit 2efd8ed167
1 changed files with 23 additions and 15 deletions

View File

@ -47,7 +47,9 @@ def test_remote_error(arb_addr, args_err):
args, errtype = args_err args, errtype = args_err
async def main(): async def main():
async with tractor.open_nursery() as nursery: async with tractor.open_nursery(
arbiter_addr=arb_addr,
) as nursery:
portal = await nursery.run_in_actor( portal = await nursery.run_in_actor(
assert_err, name='errorer', **args assert_err, name='errorer', **args
@ -62,7 +64,7 @@ def test_remote_error(arb_addr, args_err):
raise raise
with pytest.raises(tractor.RemoteActorError) as excinfo: with pytest.raises(tractor.RemoteActorError) as excinfo:
tractor.run(main, arbiter_addr=arb_addr) trio.run(main)
# ensure boxed error is correct # ensure boxed error is correct
assert excinfo.value.type == errtype assert excinfo.value.type == errtype
@ -73,7 +75,9 @@ def test_multierror(arb_addr):
more then one actor errors. more then one actor errors.
""" """
async def main(): async def main():
async with tractor.open_nursery() as nursery: async with tractor.open_nursery(
arbiter_addr=arb_addr,
) as nursery:
await nursery.run_in_actor(assert_err, name='errorer1') await nursery.run_in_actor(assert_err, name='errorer1')
portal2 = await nursery.run_in_actor(assert_err, name='errorer2') portal2 = await nursery.run_in_actor(assert_err, name='errorer2')
@ -90,7 +94,7 @@ def test_multierror(arb_addr):
# from both subactors # from both subactors
with pytest.raises(trio.MultiError): with pytest.raises(trio.MultiError):
tractor.run(main, arbiter_addr=arb_addr) trio.run(main)
@pytest.mark.parametrize('delay', (0, 0.5)) @pytest.mark.parametrize('delay', (0, 0.5))
@ -103,7 +107,10 @@ def test_multierror_fast_nursery(arb_addr, start_method, num_subactors, delay):
to test failure during an ongoing spawning. to test failure during an ongoing spawning.
""" """
async def main(): async def main():
async with tractor.open_nursery() as nursery: async with tractor.open_nursery(
arbiter_addr=arb_addr,
) as nursery:
for i in range(num_subactors): for i in range(num_subactors):
await nursery.run_in_actor( await nursery.run_in_actor(
assert_err, assert_err,
@ -112,7 +119,7 @@ def test_multierror_fast_nursery(arb_addr, start_method, num_subactors, delay):
) )
with pytest.raises(trio.MultiError) as exc_info: with pytest.raises(trio.MultiError) as exc_info:
tractor.run(main, arbiter_addr=arb_addr) trio.run(main)
assert exc_info.type == tractor.MultiError assert exc_info.type == tractor.MultiError
err = exc_info.value err = exc_info.value
@ -134,10 +141,12 @@ def test_cancel_single_subactor(arb_addr, mechanism):
async def spawn_actor(): async def spawn_actor():
"""Spawn an actor that blocks indefinitely. """Spawn an actor that blocks indefinitely.
""" """
async with tractor.open_nursery() as nursery: async with tractor.open_nursery(
arbiter_addr=arb_addr,
) as nursery:
portal = await nursery.start_actor( portal = await nursery.start_actor(
'nothin', rpc_module_paths=[__name__], 'nothin', enable_modules=[__name__],
) )
assert (await portal.run(do_nothing)) is None assert (await portal.run(do_nothing)) is None
@ -148,10 +157,10 @@ def test_cancel_single_subactor(arb_addr, mechanism):
raise mechanism raise mechanism
if mechanism == 'nursery_cancel': if mechanism == 'nursery_cancel':
tractor.run(spawn_actor, arbiter_addr=arb_addr) trio.run(spawn_actor)
else: else:
with pytest.raises(mechanism): with pytest.raises(mechanism):
tractor.run(spawn_actor, arbiter_addr=arb_addr) trio.run(spawn_actor)
async def stream_forever(): async def stream_forever():
@ -229,7 +238,7 @@ async def test_some_cancels_all(num_actors_and_errs, start_method, loglevel):
for i in range(num_actors): for i in range(num_actors):
dactor_portals.append(await n.start_actor( dactor_portals.append(await n.start_actor(
f'deamon_{i}', f'deamon_{i}',
rpc_module_paths=[__name__], enable_modules=[__name__],
)) ))
func, kwargs = ria_func func, kwargs = ria_func
@ -395,7 +404,7 @@ def test_cancel_via_SIGINT(
await trio.sleep_forever() await trio.sleep_forever()
with pytest.raises(KeyboardInterrupt): with pytest.raises(KeyboardInterrupt):
tractor.run(main) trio.run(main)
@no_windows @no_windows
@ -430,8 +439,7 @@ def test_cancel_via_SIGINT_other_task(
os.kill(pid, signal.SIGINT) os.kill(pid, signal.SIGINT)
with pytest.raises(KeyboardInterrupt): with pytest.raises(KeyboardInterrupt):
tractor.run(main) trio.run(main)
async def spin_for(period=3): async def spin_for(period=3):
"Sync sleep." "Sync sleep."
@ -470,4 +478,4 @@ def test_cancel_while_childs_child_in_sync_sleep(
assert 0 assert 0
with pytest.raises(AssertionError): with pytest.raises(AssertionError):
tractor.run(main) trio.run(main)