From ea60a3dff979bacd1c49e2cfe2fa30c07bb3a54a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 13 Aug 2018 00:06:22 -0400 Subject: [PATCH] Test the `wait_for_actor()` api --- tests/test_discovery.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/test_discovery.py b/tests/test_discovery.py index 3e92df4..238633f 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -1,6 +1,7 @@ """ Actor "discovery" testing """ +import pytest import tractor import trio @@ -49,8 +50,15 @@ async def say_hello(other_actor): return await portal.run(__name__, 'hi') +async def say_hello_use_wait(other_actor): + async with tractor.wait_for_actor(other_actor) as portal: + result = await portal.run(__name__, 'hi') + return result + + @tractor_test -async def test_trynamic_trio(): +@pytest.mark.parametrize('func', [say_hello, say_hello_use_wait]) +async def test_trynamic_trio(func): """Main tractor entry point, the "master" process (for now acts as the "director"). """ @@ -59,15 +67,14 @@ async def test_trynamic_trio(): donny = await n.run_in_actor( 'donny', - say_hello, + func, other_actor='gretchen', ) gretchen = await n.run_in_actor( 'gretchen', - say_hello, + func, other_actor='donny', ) print(await gretchen.result()) print(await donny.result()) - await donny.cancel_actor() print("CUTTTT CUUTT CUT!!?! Donny!! You're supposed to say...")