Skip to content

[TEST]: silence pytest-asyncio deprecation warning in xdist pytester tests#103

Open
spencrr wants to merge 2 commits into
microsoft:mainfrom
spencrr:dev/spencrr/pytester-asyncio-warnings
Open

[TEST]: silence pytest-asyncio deprecation warning in xdist pytester tests#103
spencrr wants to merge 2 commits into
microsoft:mainfrom
spencrr:dev/spencrr/pytester-asyncio-warnings

Conversation

@spencrr

@spencrr spencrr commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

The tests/unit/pytest_plugin/test_xdist_aggregation.py suite spawns child pytest sessions via pytester. Each child session is configuration-isolated from the repository's pyproject.toml, so pytest-asyncio read an empty asyncio_default_fixture_loop_scope via config.getini(...) and emitted a PytestDeprecationWarning once per subprocess run (14 warnings across the suite).

This PR resolves the warnings by writing a minimal ini file into each child project root that mirrors the parent project's asyncio configuration (asyncio_mode = auto, asyncio_default_fixture_loop_scope = session), so the option is supplied through the same channel pytest-asyncio actually reads.

To keep it DRY, the child conftest and ini creation are consolidated into a single configured_pytester fixture that every test now depends on, removing the scattered per-test pytester.makeconftest(...) boilerplate (and the now-unnecessary # pyright: ignore comments on makepyfile(...)).

Result: 13 passed, warning-free.

Alternatives considered

  • Set the option from the child conftest.py pytest_configure hook — e.g. config.option.asyncio_default_fixture_loop_scope = "function" or config.addinivalue_line("asyncio_default_fixture_loop_scope", "function"). Rejected: pytest-asyncio reads the value via config.getini("asyncio_default_fixture_loop_scope"), so the config.option namespace is never consulted, and addinivalue_line only appends to line-list ini options (e.g. markers, filterwarnings), not a scalar string option. Neither reaches getini(...), so the warning persisted.
  • Pass -o asyncio_default_fixture_loop_scope=session to every runpytest(...) — Works, but repeats the override across ~14 call sites; the ini file centralizes it in one place.
  • Disable the plugin per child run via -p no:asyncio — Silences the warning (the child sessions are all synchronous), but diverges from the real project configuration and sidesteps configuring the very option these tests should exercise.
  • Ignore it via filterwarnings — A band-aid that hides the symptom rather than setting the option, and would also mask the warning if it ever surfaced legitimately elsewhere.

Breaking changes

None.

Checklist

  • pre-commit run --all-files passes
  • Tests added or updated for changes
  • Documentation updated

@spencrr spencrr requested a review from a team July 7, 2026 01:18
@spencrr spencrr enabled auto-merge (squash) July 7, 2026 20:33
spencrr added a commit that referenced this pull request Jul 7, 2026
## Description

Drop references to `pyright` following #86. Some other refs dropped in
#103 too. This PR gets the rest (which are only in
`rampart/surfaces/onedrive.py`.


## Breaking changes
None

## Checklist

- [X] `pre-commit run --all-files` passes
- [ ] Tests added or updated for changes <!-- Please describe what tests
were added or updated -->
- [ ] Documentation updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant