Skip cluster test on UDS, wire `tpt_proto` fixture
Add UDS skip-guard to `test_streaming_to_actor_cluster()` and plumb `tpt_proto` through the `@tractor_test` wrapper so transport-parametrized tests can receive it. Deats, - skip cluster test when `tpt_proto == 'uds'` with descriptive msg, add TODO about `@pytest.mark.no_tpt`. - add `tpt_proto: str|None` param to inner wrapper in `tractor_test()`, forward to decorated fn when its sig accepts it. - register custom `no_tpt` marker via `pytest_configure()` to avoid unknown-marker warnings. - add masked todo for `no_tpt` marker-check code in `tpt_proto` fixture (needs fn-scope to work, left as TODO). - add `request` param to `tpt_proto` fixture for future marker inspection. Also, - add doc-string to `test_streaming_to_actor_cluster()`. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codens_aware
parent
4092db60b2
commit
99577b719a
|
|
@ -11,7 +11,6 @@ MESSAGE = 'tractoring at full speed'
|
||||||
|
|
||||||
|
|
||||||
def test_empty_mngrs_input_raises() -> None:
|
def test_empty_mngrs_input_raises() -> None:
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
with trio.fail_after(3):
|
with trio.fail_after(3):
|
||||||
async with (
|
async with (
|
||||||
|
|
@ -60,8 +59,21 @@ async def worker(
|
||||||
# assert 0
|
# assert 0
|
||||||
|
|
||||||
|
|
||||||
|
# ?TODO, but needs a fn-scoped tpt_proto fixture..
|
||||||
|
# @pytest.mark.no_tpt('uds')
|
||||||
@tractor_test
|
@tractor_test
|
||||||
async def test_streaming_to_actor_cluster():
|
async def test_streaming_to_actor_cluster(
|
||||||
|
tpt_proto: str,
|
||||||
|
):
|
||||||
|
'''
|
||||||
|
Open an actor "cluster" using the (experimental) `._clustering`
|
||||||
|
API and conduct standard inter-task-ctx streaming.
|
||||||
|
|
||||||
|
'''
|
||||||
|
if tpt_proto == 'uds':
|
||||||
|
pytest.skip(
|
||||||
|
f'Test currently fails with tpt-proto={tpt_proto!r}\n'
|
||||||
|
)
|
||||||
|
|
||||||
with trio.fail_after(6):
|
with trio.fail_after(6):
|
||||||
async with (
|
async with (
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ def tractor_test(fn):
|
||||||
reg_addr=None,
|
reg_addr=None,
|
||||||
start_method: str|None = None,
|
start_method: str|None = None,
|
||||||
debug_mode: bool = False,
|
debug_mode: bool = False,
|
||||||
|
tpt_proto: str|None=None,
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
# __tracebackhide__ = True
|
# __tracebackhide__ = True
|
||||||
|
|
@ -102,6 +103,9 @@ def tractor_test(fn):
|
||||||
# set of subprocess spawning backends
|
# set of subprocess spawning backends
|
||||||
kwargs['debug_mode'] = debug_mode
|
kwargs['debug_mode'] = debug_mode
|
||||||
|
|
||||||
|
if 'tpt_proto' in inspect.signature(fn).parameters:
|
||||||
|
# set of subprocess spawning backends
|
||||||
|
kwargs['tpt_proto'] = tpt_proto
|
||||||
|
|
||||||
if kwargs:
|
if kwargs:
|
||||||
|
|
||||||
|
|
@ -177,6 +181,13 @@ def pytest_configure(config):
|
||||||
backend = config.option.spawn_backend
|
backend = config.option.spawn_backend
|
||||||
tractor._spawn.try_set_start_method(backend)
|
tractor._spawn.try_set_start_method(backend)
|
||||||
|
|
||||||
|
# register custom marks to avoid warnings see,
|
||||||
|
# https://docs.pytest.org/en/stable/how-to/writing_plugins.html#registering-custom-markers
|
||||||
|
config.addinivalue_line(
|
||||||
|
'markers',
|
||||||
|
'no_tpt(proto_key): test will (likely) not behave with tpt backend'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def debug_mode(request) -> bool:
|
def debug_mode(request) -> bool:
|
||||||
|
|
@ -225,10 +236,26 @@ def tpt_protos(request) -> list[str]:
|
||||||
autouse=True,
|
autouse=True,
|
||||||
)
|
)
|
||||||
def tpt_proto(
|
def tpt_proto(
|
||||||
|
request,
|
||||||
tpt_protos: list[str],
|
tpt_protos: list[str],
|
||||||
) -> str:
|
) -> str:
|
||||||
proto_key: str = tpt_protos[0]
|
proto_key: str = tpt_protos[0]
|
||||||
|
|
||||||
|
# ?TODO, but needs a fn-scoped tpt_proto fixture..
|
||||||
|
# @pytest.mark.no_tpt('uds')
|
||||||
|
# node = request.node
|
||||||
|
# markers = node.own_markers
|
||||||
|
# for mark in markers:
|
||||||
|
# if (
|
||||||
|
# mark.name == 'no_tpt'
|
||||||
|
# and
|
||||||
|
# proto_key in mark.args
|
||||||
|
# ):
|
||||||
|
# pytest.skip(
|
||||||
|
# f'Test {node} normally fails with '
|
||||||
|
# f'tpt-proto={proto_key!r}\n'
|
||||||
|
# )
|
||||||
|
|
||||||
from tractor import _state
|
from tractor import _state
|
||||||
if _state._def_tpt_proto != proto_key:
|
if _state._def_tpt_proto != proto_key:
|
||||||
_state._def_tpt_proto = proto_key
|
_state._def_tpt_proto = proto_key
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue