Allow per-call `start_method`/`loglevel` overrides
In `tests/devx/conftest.py::spawn`, refactor the fixture-internal closures so consumer tests can pass explicit `start_method`/`loglevel` to each `_spawn()` invocation rather than only inheriting the fixture- scoped parametrize values. Deats, - promote `set_spawn_method()` and `set_loglevel()` to take their respective values as fn params (vs closing over the fixture-scope vars). - give `_spawn()` `start_method=start_method` and `loglevel: str|None = None` kwargs so callers override one-off without re-parametrizing the suite. NOTE: this drops the implicit fixture- scoped `loglevel` forward — `_spawn()` callers now must pass `loglevel=...` explicitly. - TODO: figure out how `--ll <level>` should map to the default (currently `None` → uses env-var or tractor default). - add a docstring to `_spawn()` so its role as the consumer-facing closure is obvious from `help()`. Also, - `assert_before()` now returns the `.before` output on success (was `None`); add a one-line docstring describing the new return contract. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-codesubint_forkserver_backend
parent
8bc304f094
commit
486249d74f
|
|
@ -96,7 +96,9 @@ def spawn(
|
||||||
# disable all ANSI color output
|
# disable all ANSI color output
|
||||||
# os.environ['NO_COLOR'] = '1'
|
# os.environ['NO_COLOR'] = '1'
|
||||||
|
|
||||||
def set_spawn_method():
|
def set_spawn_method(
|
||||||
|
start_method: str,
|
||||||
|
):
|
||||||
'''
|
'''
|
||||||
Drive the actor-spawn backend inside the spawned
|
Drive the actor-spawn backend inside the spawned
|
||||||
`examples/debugging/<script>.py` subproc via env-var
|
`examples/debugging/<script>.py` subproc via env-var
|
||||||
|
|
@ -106,7 +108,9 @@ def spawn(
|
||||||
'''
|
'''
|
||||||
os.environ['TRACTOR_SPAWN_METHOD'] = start_method
|
os.environ['TRACTOR_SPAWN_METHOD'] = start_method
|
||||||
|
|
||||||
def set_loglevel():
|
def set_loglevel(
|
||||||
|
loglevel: str|None,
|
||||||
|
):
|
||||||
'''
|
'''
|
||||||
Forward the test-suite parametrized `loglevel` into the
|
Forward the test-suite parametrized `loglevel` into the
|
||||||
spawned `examples/debugging/<script>.py` subproc via
|
spawned `examples/debugging/<script>.py` subproc via
|
||||||
|
|
@ -125,12 +129,24 @@ def spawn(
|
||||||
def _spawn(
|
def _spawn(
|
||||||
cmd: str,
|
cmd: str,
|
||||||
expect_timeout: float = 4,
|
expect_timeout: float = 4,
|
||||||
|
start_method: str = start_method,
|
||||||
|
loglevel: str|None = None,
|
||||||
**mkcmd_kwargs,
|
**mkcmd_kwargs,
|
||||||
) -> pty_spawn.spawn:
|
) -> pty_spawn.spawn:
|
||||||
|
'''
|
||||||
|
Inner closure handed to consumer tests to invoke
|
||||||
|
`pytest.Pytester.spawn`
|
||||||
|
|
||||||
|
'''
|
||||||
nonlocal spawned
|
nonlocal spawned
|
||||||
unset_colors()
|
unset_colors()
|
||||||
set_spawn_method()
|
set_spawn_method(start_method=start_method)
|
||||||
set_loglevel()
|
set_loglevel(
|
||||||
|
loglevel=loglevel,
|
||||||
|
# ?TODO^ when should this be set by `--ll <level>` ?
|
||||||
|
# by default we apply 'error' but there should be a diff
|
||||||
|
# vs. when the flag IS NOT passed?
|
||||||
|
)
|
||||||
spawned = testdir.spawn(
|
spawned = testdir.spawn(
|
||||||
cmd=mk_cmd(
|
cmd=mk_cmd(
|
||||||
cmd,
|
cmd,
|
||||||
|
|
@ -322,10 +338,13 @@ def in_prompt_msg(
|
||||||
def assert_before(
|
def assert_before(
|
||||||
child: SpawnBase,
|
child: SpawnBase,
|
||||||
patts: list[str],
|
patts: list[str],
|
||||||
|
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
) -> str:
|
||||||
|
'''
|
||||||
|
Assert a patter is in `child.before.decode() -> str`,
|
||||||
|
return the full `.before` output on success.
|
||||||
|
|
||||||
) -> None:
|
'''
|
||||||
__tracebackhide__: bool = False
|
__tracebackhide__: bool = False
|
||||||
|
|
||||||
assert in_prompt_msg(
|
assert in_prompt_msg(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue