From cd6509b724c7d62904581135f389b1384af5f2e7 Mon Sep 17 00:00:00 2001 From: goodboy Date: Sun, 29 Mar 2026 17:30:41 -0400 Subject: [PATCH] Fix `tractor_test` kwarg check and Windows `start_method` default - Use `kw in kwargs` membership test instead of `kwargs[kw]` to avoid `KeyError` on missing params. - Restructure Windows `start_method` logic to properly default to `'trio'` when unset; only raise on an explicit non-trio value. Review: PR #427 (Copilot) https://github.com/goodboy/tractor/pull/427#pullrequestreview-4009934142 (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- tractor/_testing/pytest.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tractor/_testing/pytest.py b/tractor/_testing/pytest.py index ec65abc4..dc996499 100644 --- a/tractor/_testing/pytest.py +++ b/tractor/_testing/pytest.py @@ -118,18 +118,13 @@ def tractor_test( 'timeout', ]: if kw in inspect.signature(wrapped).parameters: - assert kwargs[kw] + assert kw in kwargs - if ( - (start_method := kwargs.get('start_method')) - is - None - ): - if ( - platform.system() == "Windows" - and - start_method != 'trio' - ): + start_method = kwargs.get('start_method') + if platform.system() == "Windows": + if start_method is None: + kwargs['start_method'] = 'trio' + elif start_method != 'trio': raise ValueError( 'ONLY the `start_method="trio"` is supported on Windows.' )