forked from pytest-dev/pytest-asyncio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preprocess async fixtures for each event loop
Caching of fixture preprocessing is now also keyed by event loop id, sync fixtures can be processed if they are wrapping a async fixture, each async fixture has a mapping from root scope names to fixture id that is now used to dynamically get the event loop fixture. This fixes pytest-dev#862.
- Loading branch information
Showing
2 changed files
with
96 additions
and
31 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) |