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

Open
goodboy wants to merge 7 commits from pytest_pluginize into structural_dynamics_of_flow

More or less just exposing a buncha handy pytest fixtures and a couple hooks (mostly for CLI flags) via tractor._testing.pytest.

Turns out to be super useful in dependent projects which want to at least partially avoid rolling it all themselves when testing anything close-ish to the runtime.

More or less just exposing a buncha handy `pytest` fixtures and a couple hooks (mostly for CLI flags) via `tractor._testing.pytest`. Turns out to be super useful in dependent projects which want to at least partially avoid rolling it all themselves when testing anything close-ish to the runtime.
goodboy added 7 commits 2025-05-12 04:45:58 +00:00
fe23331365 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.
0ccf83d520 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.
a92d0ebf02 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
06f7f2e06b 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.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
You can also view command line instructions.

Step 1:

From your project repository, check out a new branch and test the changes.
git checkout -b pytest_pluginize structural_dynamics_of_flow
git pull origin pytest_pluginize

Step 2:

Merge the changes and update on Gitea.
git checkout structural_dynamics_of_flow
git merge --no-ff pytest_pluginize
git push origin structural_dynamics_of_flow
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: goodboy/tractor#27
There is no content yet.