Skip to content

test: Add concurrent fixture teardown test for Hypothesis #1190

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 3 commits into
base: main
Choose a base branch
from

Conversation

pankaj-bind
Copy link

This PR improves test coverage for the Hypothesis integration by adding a new test case for concurrent fixture teardowns.

The new test_hypothesis_concurrent_fixture_teardown test validates that async fixtures with teardown logic behave correctly when run alongside other concurrent tasks. This helps ensure the robustness of pytest-asyncio's fixture management in complex, real-world scenarios.

To accommodate Hypothesis's health checks for function-scoped fixtures, the test is decorated with @settings(suppress_health_check=[HealthCheck.function_scoped_fixture]).

@codecov-commenter
Copy link

codecov-commenter commented Aug 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.40%. Comparing base (3ab1fea) to head (8181308).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1190      +/-   ##
==========================================
+ Coverage   88.91%   89.40%   +0.49%     
==========================================
  Files           2        2              
  Lines         406      406              
  Branches       44       44              
==========================================
+ Hits          361      363       +2     
+ Misses         35       34       -1     
+ Partials       10        9       -1     

☔ 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.

Copy link
Contributor

@seifertm seifertm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.

I'm not sure if the new test is worth adding.

@pankaj-bind Can you explain what prompted you to write it?

@pankaj-bind
Copy link
Author

Hey! Good question. I was thinking about potential edge cases and realized we weren't testing how async fixture teardowns behave when a Hypothesis test also runs other concurrent tasks.

It's not fixing a current bug, but I figured it would be a good way to make our test suite a bit more robust and catch potential race conditions in the future. Just a small addition to prevent future headaches! Happy to discuss it more though.

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.

3 participants