-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] Added optional "loop_scope" argument to pytest_asyncio.fixture.
Signed-off-by: Michael Seifert <[email protected]>
- Loading branch information
Showing
2 changed files
with
32 additions
and
6 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,19 @@ | ||
import asyncio | ||
|
||
import pytest | ||
|
||
import pytest_asyncio | ||
|
||
loop: asyncio.AbstractEventLoop | ||
|
||
|
||
@pytest_asyncio.fixture(loop_scope="session") | ||
async def fixture(): | ||
global loop | ||
loop = asyncio.get_running_loop() | ||
|
||
|
||
@pytest.mark.asyncio(scope="session") | ||
async def test_fixture_loop_scopes(fixture): | ||
global loop | ||
assert loop == asyncio.get_running_loop() |