From cb527c2562e5f8fd42800be40fdb122f35627c10 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 24 Feb 2021 14:59:48 -0500 Subject: [PATCH] Mostly drop run from local tests --- tests/test_local.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/test_local.py b/tests/test_local.py index 60e875b..016df3f 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -15,8 +15,8 @@ async def test_no_arbitter(): """An arbitter must be established before any nurseries can be created. - (In other words ``tractor.run`` must be used instead of ``trio.run`` as is - done by the ``pytest-trio`` plugin.) + (In other words ``tractor.open_root_actor()`` must be engaged at + some point?) """ with pytest.raises(RuntimeError): with tractor.open_nursery(): @@ -49,7 +49,8 @@ async def test_self_is_registered_localportal(arb_addr): assert isinstance(portal, tractor._portal.LocalPortal) with trio.fail_after(0.2): - sockaddr = await portal.run_from_ns('self', 'wait_for_actor', name='root') + sockaddr = await portal.run_from_ns( + 'self', 'wait_for_actor', name='root') assert sockaddr[0] == arb_addr @@ -59,15 +60,19 @@ def test_local_actor_async_func(arb_addr): nums = [] async def print_loop(): - # arbiter is started in-proc if dne - assert tractor.current_actor().is_arbiter - for i in range(10): - nums.append(i) - await trio.sleep(0.1) + async with tractor.open_root_actor( + arbiter_addr=arb_addr, + ): + # arbiter is started in-proc if dne + assert tractor.current_actor().is_arbiter + + for i in range(10): + nums.append(i) + await trio.sleep(0.1) start = time.time() - tractor.run(print_loop, arbiter_addr=arb_addr) + trio.run(print_loop) # ensure the sleeps were actually awaited assert time.time() - start >= 1