-
Notifications
You must be signed in to change notification settings - Fork 160
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
======================================================= | ||
How to change the default event loop scope of all tests | ||
======================================================= | ||
The :ref:`configuration/asyncio_default_test_loop_scope` configuration option sets the default event loop scope for asynchronous tests. The following code snippets configure all tests to run in a session-scoped loop by default: | ||
|
||
.. code-block:: ini | ||
:caption: pytest.ini | ||
|
||
[pytest] | ||
asyncio_default_test_loop_scope = session | ||
|
||
.. code-block:: toml | ||
:caption: pyproject.toml | ||
|
||
[tool.pytest.ini_options] | ||
asyncio_default_test_loop_scope = "session" | ||
|
||
.. code-block:: ini | ||
:caption: setup.cfg | ||
|
||
[tool:pytest] | ||
asyncio_default_test_loop_scope = session | ||
|
||
Please refer to :ref:`configuration/asyncio_default_test_loop_scope` for other valid scopes. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,10 @@ How-To Guides | |
migrate_from_0_23 | ||
change_fixture_loop | ||
change_default_fixture_loop | ||
change_default_test_loop | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How-to removed |
||
run_class_tests_in_same_loop | ||
run_module_tests_in_same_loop | ||
run_package_tests_in_same_loop | ||
run_session_tests_in_same_loop | ||
multiple_loops | ||
uvloop | ||
test_item_is_async | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
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.
It's nothing short of great that you even included a how-to guide for the new approach, thanks!
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.
just a bit of copy-paste ;)