Test Overview
This test uses an async fixture to set up a resource before the test runs. It verifies that the async fixture provides the expected value to the test function.
This test uses an async fixture to set up a resource before the test runs. It verifies that the async fixture provides the expected value to the test function.
import pytest import asyncio @pytest.fixture async def async_resource(): await asyncio.sleep(0.1) # Simulate async setup return "resource_ready" @pytest.mark.asyncio async def test_async_fixture(async_resource): assert async_resource == "resource_ready"
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | pytest test runner initialized with pytest-asyncio plugin | - | PASS |
| 2 | pytest discovers test_async_fixture and async_resource fixture | Test and fixture functions loaded | - | PASS |
| 3 | pytest calls async_resource fixture asynchronously | async_resource fixture running, awaiting asyncio.sleep(0.1) | - | PASS |
| 4 | async_resource fixture returns value 'resource_ready' | Fixture setup complete, value ready for test | - | PASS |
| 5 | pytest calls test_async_fixture with async_resource value | Test function running with async_resource='resource_ready' | assert async_resource == 'resource_ready' | PASS |
| 6 | Test completes successfully | Test passed, no errors | - | PASS |