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
multicast_revertable_streams
Gud Boi 2026-03-29 17:30:41 -04:00
parent 93d99ed2eb
commit cd6509b724
1 changed files with 6 additions and 11 deletions

View File

@ -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.'
)