forked from pytest-dev/pytest-asyncio
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconftest.py
31 lines (23 loc) · 817 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import asyncio
import sys
import pytest
collect_ignore = []
if sys.version_info[:2] < (3, 6):
collect_ignore.append("async_fixtures/test_async_gen_fixtures_36.py")
collect_ignore.append("async_fixtures/test_nested_36.py")
if sys.version_info[:2] < (3, 7):
collect_ignore.append("async_fixtures/test_async_gen_fixtures_within_context_37.py")
@pytest.fixture
def dependent_fixture(event_loop):
"""A fixture dependent on the event_loop fixture, doing some cleanup."""
counter = 0
async def just_a_sleep():
"""Just sleep a little while."""
nonlocal event_loop
await asyncio.sleep(0.1)
nonlocal counter
counter += 1
event_loop.run_until_complete(just_a_sleep())
yield
event_loop.run_until_complete(just_a_sleep())
assert counter == 2