| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import asyncio |
| 4 |
|
| 5 |
import pytest |
| 6 |
|
| 7 |
|
| 8 |
@pytest.fixture() |
| 9 |
async def async_inner_fixture(): |
| 10 |
await asyncio.sleep(0.01) |
| 11 |
print("inner start") |
| 12 |
yield True |
| 13 |
print("inner stop") |
| 14 |
|
| 15 |
|
| 16 |
@pytest.fixture() |
| 17 |
async def async_fixture_outer(async_inner_fixture): |
| 18 |
await asyncio.sleep(0.01) |
| 19 |
print("outer start") |
| 20 |
assert async_inner_fixture is True |
| 21 |
yield True |
| 22 |
print("outer stop") |
| 23 |
|
| 24 |
|
| 25 |
@pytest.mark.asyncio |
| 26 |
async def test_async_fixture(async_fixture_outer): |
| 27 |
assert async_fixture_outer is True |
| 28 |
print("test_async_fixture") |