forked from goodboy/tractor
Flip tests to use `start_method` kwarg
parent
c3daf73112
commit
b70f4eafcb
|
@ -31,8 +31,8 @@ def arb_addr():
|
||||||
|
|
||||||
|
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
if 'spawn_method' in metafunc.fixturenames:
|
if 'start_method' in metafunc.fixturenames:
|
||||||
from multiprocessing import get_all_start_methods
|
from multiprocessing import get_all_start_methods
|
||||||
methods = get_all_start_methods()
|
methods = get_all_start_methods()
|
||||||
methods.remove('fork')
|
methods.remove('fork')
|
||||||
metafunc.parametrize("spawn_method", methods, scope='module')
|
metafunc.parametrize("start_method", methods, scope='module')
|
||||||
|
|
|
@ -110,7 +110,7 @@ async def stream_forever():
|
||||||
|
|
||||||
|
|
||||||
@tractor_test
|
@tractor_test
|
||||||
async def test_cancel_infinite_streamer(spawn_method):
|
async def test_cancel_infinite_streamer(start_method):
|
||||||
|
|
||||||
# stream for at most 1 seconds
|
# stream for at most 1 seconds
|
||||||
with trio.move_on_after(1) as cancel_scope:
|
with trio.move_on_after(1) as cancel_scope:
|
||||||
|
@ -139,7 +139,7 @@ async def test_cancel_infinite_streamer(spawn_method):
|
||||||
ids=['one_actor', 'two_actors'],
|
ids=['one_actor', 'two_actors'],
|
||||||
)
|
)
|
||||||
@tractor_test
|
@tractor_test
|
||||||
async def test_some_cancels_all(num_actors_and_errs, spawn_method):
|
async def test_some_cancels_all(num_actors_and_errs, start_method):
|
||||||
"""Verify a subset of failed subactors causes all others in
|
"""Verify a subset of failed subactors causes all others in
|
||||||
the nursery to be cancelled just like the strategy in trio.
|
the nursery to be cancelled just like the strategy in trio.
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ def movie_theatre_question():
|
||||||
|
|
||||||
|
|
||||||
@tractor_test
|
@tractor_test
|
||||||
async def test_movie_theatre_convo(spawn_method):
|
async def test_movie_theatre_convo(start_method):
|
||||||
"""The main ``tractor`` routine.
|
"""The main ``tractor`` routine.
|
||||||
"""
|
"""
|
||||||
async with tractor.open_nursery() as n:
|
async with tractor.open_nursery() as n:
|
||||||
|
@ -83,7 +83,7 @@ def cellar_door():
|
||||||
|
|
||||||
|
|
||||||
@tractor_test
|
@tractor_test
|
||||||
async def test_most_beautiful_word(spawn_method):
|
async def test_most_beautiful_word(start_method):
|
||||||
"""The main ``tractor`` routine.
|
"""The main ``tractor`` routine.
|
||||||
"""
|
"""
|
||||||
async with tractor.open_nursery() as n:
|
async with tractor.open_nursery() as n:
|
||||||
|
|
|
@ -62,13 +62,13 @@ async def stream_from_single_subactor():
|
||||||
# await nursery.cancel()
|
# await nursery.cancel()
|
||||||
|
|
||||||
|
|
||||||
def test_stream_from_single_subactor(arb_addr, spawn_method):
|
def test_stream_from_single_subactor(arb_addr, start_method):
|
||||||
"""Verify streaming from a spawned async generator.
|
"""Verify streaming from a spawned async generator.
|
||||||
"""
|
"""
|
||||||
tractor.run(
|
tractor.run(
|
||||||
stream_from_single_subactor,
|
stream_from_single_subactor,
|
||||||
arbiter_addr=arb_addr,
|
arbiter_addr=arb_addr,
|
||||||
spawn_method=spawn_method,
|
start_method=start_method,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ def tractor_test(fn):
|
||||||
*args,
|
*args,
|
||||||
loglevel=None,
|
loglevel=None,
|
||||||
arb_addr=None,
|
arb_addr=None,
|
||||||
spawn_method='forkserver',
|
start_method='forkserver',
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
# __tracebackhide__ = True
|
# __tracebackhide__ = True
|
||||||
|
@ -40,15 +40,15 @@ def tractor_test(fn):
|
||||||
# allows test suites to define a 'loglevel' fixture
|
# allows test suites to define a 'loglevel' fixture
|
||||||
# that activates the internal logging
|
# that activates the internal logging
|
||||||
kwargs['loglevel'] = loglevel
|
kwargs['loglevel'] = loglevel
|
||||||
if 'spawn_method' in inspect.signature(fn).parameters:
|
if 'start_method' in inspect.signature(fn).parameters:
|
||||||
# allows test suites to define a 'loglevel' fixture
|
# allows test suites to define a 'loglevel' fixture
|
||||||
# that activates the internal logging
|
# that activates the internal logging
|
||||||
kwargs['spawn_method'] = spawn_method
|
kwargs['start_method'] = start_method
|
||||||
return run(
|
return run(
|
||||||
partial(fn, *args, **kwargs),
|
partial(fn, *args, **kwargs),
|
||||||
arbiter_addr=arb_addr,
|
arbiter_addr=arb_addr,
|
||||||
loglevel=loglevel,
|
loglevel=loglevel,
|
||||||
spawn_method=spawn_method,
|
start_method=start_method,
|
||||||
)
|
)
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
Loading…
Reference in New Issue