-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fixes a bug that caused module-scoped async fixtures to fail whe…
…n reused in other modules. Async fixture synchronizers now choose the event loop for the async fixutre at runtime rather than relying on collection-time information. This fixes #862.
- Loading branch information
Showing
2 changed files
with
78 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from textwrap import dedent | ||
|
||
from pytest import Pytester | ||
|
||
|
||
def test_asyncio_mark_provides_package_scoped_loop_strict_mode(pytester: Pytester): | ||
pytester.makepyfile( | ||
__init__="", | ||
conftest=dedent( | ||
"""\ | ||
import pytest_asyncio | ||
@pytest_asyncio.fixture(scope="module") | ||
async def async_shared_module_fixture(): | ||
return True | ||
""" | ||
), | ||
test_module_one=dedent( | ||
"""\ | ||
import pytest | ||
@pytest.mark.asyncio | ||
async def test_shared_module_fixture_use_a(async_shared_module_fixture): | ||
assert async_shared_module_fixture is True | ||
""" | ||
), | ||
test_module_two=dedent( | ||
"""\ | ||
import pytest | ||
@pytest.mark.asyncio | ||
async def test_shared_module_fixture_use_b(async_shared_module_fixture): | ||
assert async_shared_module_fixture is True | ||
""" | ||
), | ||
) | ||
result = pytester.runpytest("--asyncio-mode=strict") | ||
result.assert_outcomes(passed=2) |