From 99577b719a7645e4f9480c06a52d4a595c0ef8be Mon Sep 17 00:00:00 2001 From: goodboy Date: Fri, 13 Mar 2026 13:36:47 -0400 Subject: [PATCH] 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-code --- tests/test_clustering.py | 16 ++++++++++++++-- tractor/_testing/pytest.py | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/tests/test_clustering.py b/tests/test_clustering.py index 33281f08..308a92a2 100644 --- a/tests/test_clustering.py +++ b/tests/test_clustering.py @@ -11,7 +11,6 @@ MESSAGE = 'tractoring at full speed' def test_empty_mngrs_input_raises() -> None: - async def main(): with trio.fail_after(3): async with ( @@ -60,8 +59,21 @@ async def worker( # assert 0 +# ?TODO, but needs a fn-scoped tpt_proto fixture.. +# @pytest.mark.no_tpt('uds') @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): async with ( diff --git a/tractor/_testing/pytest.py b/tractor/_testing/pytest.py index 65a34da1..a0d0d0d5 100644 --- a/tractor/_testing/pytest.py +++ b/tractor/_testing/pytest.py @@ -74,6 +74,7 @@ def tractor_test(fn): reg_addr=None, start_method: str|None = None, debug_mode: bool = False, + tpt_proto: str|None=None, **kwargs ): # __tracebackhide__ = True @@ -102,6 +103,9 @@ def tractor_test(fn): # set of subprocess spawning backends 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: @@ -177,6 +181,13 @@ def pytest_configure(config): backend = config.option.spawn_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') def debug_mode(request) -> bool: @@ -225,10 +236,26 @@ def tpt_protos(request) -> list[str]: autouse=True, ) def tpt_proto( + request, tpt_protos: list[str], ) -> str: 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 if _state._def_tpt_proto != proto_key: _state._def_tpt_proto = proto_key