Skip to content

Fix: Add validation for asyncio_default_fixture_loop_scope #1189

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

Conversation

pankaj-bind
Copy link

This PR addresses an issue where the asyncio_default_fixture_loop_scope configuration option in pytest.ini was not being validated. This could lead to misconfigurations and unexpected behavior without providing any feedback to the user.

This change introduces a validation check in pytest_asyncio/plugin.py to ensure that the provided scope is one of the valid options (function, class, module, package, or session). If an invalid scope is provided, a pytest.UsageError is raised with a descriptive error message.

Additionally, a new test case has been added to tests/test_fixture_loop_scopes.py to verify that an invalid scope configuration correctly raises an error.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.64%. Comparing base (4fbe1e0) to head (b60df08).

Files with missing lines Patch % Lines
pytest_asyncio/plugin.py 72.72% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1189      +/-   ##
==========================================
- Coverage   88.88%   88.64%   -0.25%     
==========================================
  Files           2        2              
  Lines         405      414       +9     
  Branches       44       46       +2     
==========================================
+ Hits          360      367       +7     
- Misses         35       36       +1     
- Partials       10       11       +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.

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.

2 participants