pytest_pluginize: expose some pytest reusables from our test harness #27

Open
goodboy wants to merge 8 commits from pytest_pluginize into structural_dynamics_of_flow

8 Commits (main)

Author SHA1 Message Date
Tyler Goodlet 48b6db5c68 Add a `debug_mode`-state reversion test 2025-06-11 21:35:59 -04:00
Tyler Goodlet 029888cee8 Fix ref-err on `logger` input to `get_console_log()`
Particularly on a get-attr of `StackLevelAdapter.handlers` which, when
a `logger: StackLevelAdapter` is passed, we need to *not call* our own
`get_logger()` and just set is as the `log`. Fix the typing to match.
2025-06-11 21:35:59 -04:00
Tyler Goodlet 223d885e22 Unset debug-mode on root actor exit
Discovered this bug while testing `modden`'s daemon under various
cancelled-while-booting race conditions where sequential tests would
fail a lingering `assert 0` inside `.to_asyncio.run_as_asyncio_guest()`
to (oddly) catch redundant greenback-re-inits..

XD

Needs a test likely ;P
2025-06-11 21:35:59 -04:00
Tyler Goodlet a1f091882e Expose `.trionics.maybe_collapse_eg` 2025-06-11 21:35:59 -04:00
Tyler Goodlet e587f0da23 Use `.is_debug_mode()` for maybe-crash-handling
Such that the default is `None` and in the case where the caller *does
not* set the `pdb` arg to an explicit `bool` we instead determine it via
the output from `._state.is_debug_mode()` allowing for more "nonchalant"
usage throughout a (test) code base which passes the `debug_mode: bool`
as runtime config; allows delegation to the per-actor proc-global state.
2025-06-11 21:35:59 -04:00
Tyler Goodlet 5138224625 Add todo for `dulwhich` as dep 2025-06-11 21:35:59 -04:00
Tyler Goodlet ad72cd629f Plugin-ize some re-usable `conftest` parts
Namely any CLI driven runtime-config fixtures such as,

- `--spawn-backend` and `start_method`,
- `--tpdb` and `debug_mode`,
- `--tpt-proto` and `tpt_protos`/`tpt_proto`,
- `reg_addr` as driven by the above.

This moves all fixtures and necessary hook funcs (CLI parsing,
configuring and test-gen) to the `._testing.pytest` module and thus
allows any dependent project to leverage these fixtures in their own
test suites after pointing to that plugin mod using,

```python
    # conftest.py
    pytest_plugins: tuple[str] = (
        "tractor._testing.pytest",
    )
```

Also, add a new `._testing.addr` helper mod which now contains
a factored `get_rando_addr()` helper for creating test-sesh unique
tpt-specific registry (or other) IPC endpoint addrs.
2025-06-11 21:35:59 -04:00
Tyler Goodlet 533e69baaf Formally add `nest_from_op()` XD
Moving it from where i (oddly) first wrote it up in `._entry` to a more
proper place with its pals in `.devx.pformat` ;p
2025-06-11 21:35:59 -04:00