Running without a main func is a type error

multi_program_tests
Tyler Goodlet 2018-09-05 18:13:23 -04:00
parent 914d1b67d8
commit 0ca668453c
2 changed files with 11 additions and 1 deletions

View File

@ -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.
"""

View File

@ -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()))