From da0495816b272427423b521157374a45511f815e Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 6 Jul 2018 17:27:42 -0400 Subject: [PATCH] Drop tractor unit tests --- tests/test_tractor.py | 78 +------------------------------------------ 1 file changed, 1 insertion(+), 77 deletions(-) diff --git a/tests/test_tractor.py b/tests/test_tractor.py index 7200dfb0..3027fc9f 100644 --- a/tests/test_tractor.py +++ b/tests/test_tractor.py @@ -1,12 +1,8 @@ """ Actor model API testing """ -import time -from functools import partial - import pytest -import trio -from piker import tractor +import tractor @pytest.fixture @@ -14,78 +10,6 @@ def us_symbols(): return ['TSLA', 'AAPL', 'CGC', 'CRON'] -@pytest.mark.trio -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.) - """ - with pytest.raises(RuntimeError): - with tractor.open_nursery(): - pass - - -def test_local_actor_async_func(): - """Verify a simple async function in-process. - """ - 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) - - start = time.time() - tractor.run(print_loop) - - # ensure the sleeps were actually awaited - assert time.time() - start >= 1 - assert nums == list(range(10)) - - -# NOTE: this func must be defined at module level in order for the -# interal pickling infra of the forkserver to work -async def spawn(is_arbiter): - statespace = {'doggy': 10, 'kitty': 4} - namespaces = ['piker.brokers.core'] - - await trio.sleep(0.1) - actor = tractor.current_actor() - assert actor.is_arbiter == is_arbiter - - # arbiter should always have an empty statespace as it's redundant - assert actor.statespace == statespace - - if actor.is_arbiter: - async with tractor.open_nursery() as nursery: - # forks here - portal = await nursery.start_actor( - 'sub-actor', - main=partial(spawn, False), - statespace=statespace, - rpc_module_paths=namespaces, - ) - assert len(nursery._children) == 1 - assert portal.channel.uid in tractor.current_actor()._peers - else: - return 10 - - -def test_local_arbiter_subactor_global_state(): - statespace = {'doggy': 10, 'kitty': 4} - tractor.run( - spawn, - True, - name='arbiter', - statespace=statespace, - ) - - async def rx_price_quotes_from_brokerd(us_symbols): """Verify we can spawn a daemon actor and retrieve streamed price data. """