-
Couldn't load subscription status.
- Fork 166
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
Fix: Add validation for asyncio_default_fixture_loop_scope
#1189
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1189 +/- ##
==========================================
- Coverage 90.81% 90.53% -0.29%
==========================================
Files 2 2
Lines 403 412 +9
Branches 43 45 +2
==========================================
+ Hits 366 373 +7
- Misses 29 30 +1
- Partials 8 9 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great idea! . It will give better error messages in case the user has a typo in their configuration. The code and test look solid. The only thing that's left is notifying the users about this addition in the changelog.
To add a changelog entry, you can simply add a file (aka news fragment) to changelog.d/ stating that incorrect configuration values for default_fixture_loop_scope and default_test_loop_scope now give a better error message. The news fragment should point to the underlying issue or, in this case, the PR and should have the category added. That means the complete file path for the news item is changelog.d/1189.added.rst.
I'd also appreciate if you could squash the commits in this PR (just this once), so we don't have the fixup commits from pre-commit CI in the Git history.
f583e73 to
4437281
Compare
…io_default_test_loop_scope fix linters issue added changelog entry [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci docs: Reword changelog entry.
4bd8a3b to
d00f908
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pankaj-bind !
This PR addresses an issue where the
asyncio_default_fixture_loop_scopeconfiguration option inpytest.iniwas 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.pyto ensure that the provided scope is one of the valid options (function,class,module,package, orsession). If an invalid scope is provided, apytest.UsageErroris raised with a descriptive error message.Additionally, a new test case has been added to
tests/test_fixture_loop_scopes.pyto verify that an invalid scope configuration correctly raises an error.