Skip to content
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

feat: Configuration option for setting default loop_scope for tests #1035

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Novakov
Copy link

@Novakov Novakov commented Jan 6, 2025

New configuration option, asyncio_default_test_loop_scope, provides default value for loop_scope argument of asyncio marker. This can be used to use the same event loop in auto mode without need to use modifyitems hook.

Test functions can still override loop_scope by using asyncio marker.

Implements #793

@Novakov Novakov force-pushed the config-option-default-test-loop-scope branch 3 times, most recently from d49ad4c to cb06135 Compare January 6, 2025 11:50
New configuration option, asyncio_default_test_loop_scope, provides
default value for loop_scope argument of asyncio marker. This can be
used to use the same event loop in auto mode without need to use
modifyitems hook.

Test functions can still override loop_scope by using asyncio marker.
@Novakov Novakov force-pushed the config-option-default-test-loop-scope branch from cb06135 to 5272cc4 Compare January 6, 2025 11:53
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.24%. Comparing base (623ab74) to head (5272cc4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1035      +/-   ##
==========================================
+ Coverage   91.10%   91.24%   +0.14%     
==========================================
  Files           2        2              
  Lines         562      571       +9     
  Branches       74       75       +1     
==========================================
+ Hits          512      521       +9     
  Misses         30       30              
  Partials       20       20              

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

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.

Thank you! I really like how you changed _get_marked_loop_scope and how you used functions to keep the code readable.

Can you please add an entry to docs/reference/changelog.rst where you link to #793 ?
Assume that this PR bumps the minor version and set the date to UNRELEASED.

@@ -0,0 +1,24 @@
=======================================================
Copy link
Contributor

Choose a reason for hiding this comment

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

It's nothing short of great that you even included a how-to guide for the new approach, thanks!

@@ -9,6 +9,7 @@ How-To Guides
migrate_from_0_23
change_fixture_loop
change_default_fixture_loop
change_default_test_loop
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can drop the "run_session_tests_in_same_loop" how-to guide. It's superseded by the configuration option. I cannot think of a use case where someone wants to use the pytest hook, instead of the config option.

@seifertm seifertm linked an issue Jan 8, 2025 that may be closed by this pull request
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.

Configuration option for default loop scope
3 participants