Skip to content

Synchronize fixtures on demand #1147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

seifertm
Copy link
Contributor

This is a refactoring patch which replaces the preprocessing of fixtures at collection time with on-demand fixture wrapping. The new approach more closely resembles the order in which pytest evaluates non-async fixtures and reduces the number of pytest implementation details used in the code.

Supersedes #669
Closes #668

seifertm added 10 commits June 18, 2025 08:51
…cally.

Previously, async coroutines and async generators used as fixture functions were wrapped with a fixture synchronizer during collection time. This allowed fixture function to be run as synchronous functions.

This patch changes the synchronization to occur during the pytest_fixture_setup hook. The synchronization is now temporary, which means the wrapper fixture function is restored after the fixture setup has finished.
@seifertm seifertm requested review from asvetlov and Tinche as code owners June 20, 2025 07:41
@seifertm seifertm added this to the v1.1 milestone Jun 20, 2025
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 97.67442% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.40%. Comparing base (5ef97bd) to head (dfa855f).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
pytest_asyncio/plugin.py 97.67% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1147      +/-   ##
==========================================
- Coverage   89.93%   89.40%   -0.54%     
==========================================
  Files           2        2              
  Lines         447      434      -13     
  Branches       53       51       -2     
==========================================
- Hits          402      388      -14     
- Misses         30       31       +1     
  Partials       15       15              

☔ View full report in Codecov by Sentry.
📢 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.

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.

Synchronize async fixtures dynamically
2 participants