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.
To take into account user case that sets a specific event loop policy before runnins pytest asyncio tests: - Rollover changes in V0.14 (that clears event loop policy in pytest_fixture_post_finalizer) - include a new unit test that checks if policy has been changed (fails with V0.14 and pass with this PR).
- Loading branch information
Showing
2 changed files
with
29 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,22 @@ | ||
import asyncio | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def old_policy(): | ||
policy = asyncio.get_event_loop_policy() | ||
yield policy | ||
|
||
|
||
def test_1(old_policy): | ||
assert old_policy == asyncio.get_event_loop_policy() | ||
|
||
@pytest.mark.asyncio | ||
async def test_2(old_policy): | ||
assert old_policy == asyncio.get_event_loop_policy() | ||
|
||
@pytest.mark.asyncio | ||
async def test_3(old_policy): | ||
# This test fails with pytest-asyncio V0.14 | ||
# due to a teardown change of event loop policy | ||
assert old_policy == asyncio.get_event_loop_policy() |