From 0ca668453c8dd3a6da79b60243b0c822646623e4 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 5 Sep 2018 18:13:23 -0400 Subject: [PATCH] Running without a main func is a type error --- tests/test_local.py | 10 ++++++++++ tractor/__init__.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_local.py b/tests/test_local.py index 2344f5f..3f41301 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -8,6 +8,9 @@ import trio import tractor +from conftest import tractor_test + + @pytest.mark.trio async def test_no_arbitter(): """An arbitter must be established before any nurseries @@ -21,6 +24,13 @@ async def test_no_arbitter(): pass +def test_no_main(): + """An async function **must** be passed to ``tractor.run()``. + """ + with pytest.raises(TypeError): + tractor.run(None) + + def test_local_actor_async_func(arb_addr): """Verify a simple async function in-process. """ diff --git a/tractor/__init__.py b/tractor/__init__.py index eccd5f7..d48e257 100644 --- a/tractor/__init__.py +++ b/tractor/__init__.py @@ -43,7 +43,7 @@ async def _main( """Async entry point for ``tractor``. """ log = get_logger('tractor') - main = partial(async_fn, *args) if async_fn else None + main = partial(async_fn, *args) arbiter_addr = (host, port) = arbiter_addr or ( _default_arbiter_host, _default_arbiter_port) get_console_log(kwargs.get('loglevel', get_loglevel()))