forked from goodboy/tractor
Add a `spawn_method` dynamic fixture
parent
7014a07986
commit
483ae42a46
|
@ -28,3 +28,11 @@ def loglevel(request):
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def arb_addr():
|
def arb_addr():
|
||||||
return _arb_addr
|
return _arb_addr
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_generate_tests(metafunc):
|
||||||
|
if 'spawn_method' in metafunc.fixturenames:
|
||||||
|
from multiprocessing import get_all_start_methods
|
||||||
|
methods = get_all_start_methods()
|
||||||
|
methods.remove('fork')
|
||||||
|
metafunc.parametrize("spawn_method", methods, scope='module')
|
||||||
|
|
|
@ -24,7 +24,13 @@ def tractor_test(fn):
|
||||||
injected to tests declaring these funcargs.
|
injected to tests declaring these funcargs.
|
||||||
"""
|
"""
|
||||||
@wraps(fn)
|
@wraps(fn)
|
||||||
def wrapper(*args, loglevel=None, arb_addr=None, **kwargs):
|
def wrapper(
|
||||||
|
*args,
|
||||||
|
loglevel=None,
|
||||||
|
arb_addr=None,
|
||||||
|
spawn_method='forkserver',
|
||||||
|
**kwargs
|
||||||
|
):
|
||||||
# __tracebackhide__ = True
|
# __tracebackhide__ = True
|
||||||
if 'arb_addr' in inspect.signature(fn).parameters:
|
if 'arb_addr' in inspect.signature(fn).parameters:
|
||||||
# injects test suite fixture value to test as well
|
# injects test suite fixture value to test as well
|
||||||
|
@ -34,9 +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:
|
||||||
|
# allows test suites to define a 'loglevel' fixture
|
||||||
|
# that activates the internal logging
|
||||||
|
kwargs['spawn_method'] = spawn_method
|
||||||
return run(
|
return run(
|
||||||
partial(fn, *args, **kwargs),
|
partial(fn, *args, **kwargs),
|
||||||
arbiter_addr=arb_addr, loglevel=loglevel
|
arbiter_addr=arb_addr,
|
||||||
|
loglevel=loglevel,
|
||||||
|
spawn_method=spawn_method,
|
||||||
)
|
)
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
Loading…
Reference in New Issue