Skip to content

docs: explain loop factory selection for parametrized asyncio tests - #1558

Closed
lonh-jing wants to merge 1 commit into
pytest-dev:mainfrom
lonh-jing:codex/docs-parametrized-loop-factories
Closed

lonh-jing wants to merge 1 commit into
pytest-dev:mainfrom
lonh-jing:codex/docs-parametrized-loop-factories

Conversation

@lonh-jing

Copy link
Copy Markdown

In strict mode, adding an asyncio marker only through pytest.param does not trigger loop-factory parametrization. The parametrization guide currently does not mention this limitation.

Document where to place the marker, with an executable example showing two parameter values running against two loop factories. Also explain why mixed asyncio/Trio parameter sets need separately marked test functions. The example is collected by the existing documentation test suite.

Related to #1463. This documents the existing limitation and a working usage pattern; it does not resolve the underlying runtime issue.

Validation on macOS, Python 3.13.11, pytest 9.1.1:

  • The new example passes all four cases with --asyncio-mode=strict.
  • The parameter-specific marker reproduction fails to select the configured factories in strict mode; the same reproduction selects them in auto mode. Fixture parameter marks were checked separately.
  • Sphinx builds with -n -W --keep-going; pre-commit checks pass for all changed files.
  • Full suite: baseline 294 passed, 3 skipped, 1 failed; with this patch 298 passed, 3 skipped, 1 failed. The same existing failure in test_asyncio_run_after_async_fixture_does_not_leak_loop raises PytestAssertRewriteWarning about pytest_asyncio already being imported.

AI assistance: Codex (GPT-6 Astra) assisted with investigation, documentation, and executable examples. The local behavior checks above were actually run.

Document the strict-mode limitation and provide an executable example. Related to pytest-dev#1463. AI-assisted with Codex (GPT-6 Astra).
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.50%. Comparing base (cb94811) to head (a9c03d0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1558   +/-   ##
=======================================
  Coverage   94.50%   94.50%           
=======================================
  Files           2        2           
  Lines         510      510           
  Branches       62       62           
=======================================
  Hits          482      482           
  Misses         22       22           
  Partials        6        6           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tjkuson

tjkuson commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Thanks for your interest in improving the documentation!

I'm going to close this because the working usage is already covered by the existing documentation (which this PR somewhat duplicates), and the additional restriction pertains to an unresolved bug. I'd rather keep workaround attached to that issue rather than expand the guide around it. I'll also add that although #1463 is definitely a bug we should solve, the workaround is specific to code example posted by the reporter, and not a pattern that I'd like to bless in the documentation itself.

@tjkuson tjkuson closed this Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants