-
Notifications
You must be signed in to change notification settings - Fork 184
Set default asyncio fixture loop scope to function #1444
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
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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| Improved the readability of the warning message that is displayed when ``asyncio_default_fixture_loop_scope`` is unset | ||
| The default value of ``asyncio_default_fixture_loop_scope`` is now ``function``. The deprecated unset behavior and warning have been removed. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| The default value of ``asyncio_default_fixture_loop_scope`` is now ``function``. The deprecated unset behavior and warning have been removed. |
|
Contributor
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. This is the migration guide for users looking to upgrade from an older version of pytest-asyncio. This patch doesn't change anything in the upgrade path. Please remove any modifications to this file. |
|
Contributor
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. This is the migration guide for users looking to upgrade from an older version of pytest-asyncio. This patch doesn't change anything in the upgrade path. Please remove any modifications to this file. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,29 @@ async def test_runs_in_same_loop_as_fixture(fixture): | |
| result.assert_outcomes(passed=1) | ||
|
|
||
|
|
||
| def test_default_fixture_loop_scope_is_function_when_unset(pytester: Pytester): | ||
|
Contributor
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 does this test assert that the fixture is function-scoped? In other words, how would the test fail if the fixture was not function-scoped? |
||
| pytester.makepyfile(dedent(""" | ||
| import pytest | ||
| import pytest_asyncio | ||
|
|
||
| @pytest_asyncio.fixture | ||
| async def value(): | ||
| return 1 | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_value(value): | ||
| assert value == 1 | ||
| """)) | ||
|
|
||
| result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W", "error") | ||
| result.assert_outcomes(passed=1) | ||
| result.stdout.fnmatch_lines( | ||
| [ | ||
| "*asyncio_default_fixture_loop_scope=function*", | ||
| ] | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("default_loop_scope", ("function", "module", "session")) | ||
| def test_default_loop_scope_config_option_changes_fixture_loop_scope( | ||
| pytester: Pytester, | ||
|
|
||
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.
The news fragment describes a change of a warning message. Your change is unrelated to this news fragment and will be included in a different release. Please remove any modifications to this file.