# RuntimeWarning: 协程 'test_async_func' 从未被等待

- **ID:** `python/pytest-asyncio-coroutine-not-awaited`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

异步测试函数未被等待，通常是因为测试未标记 @pytest.mark.asyncio 或 asyncio 模式未设置为 auto。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 0.21 | active | — | — |

## 解决方案

1. **** (98% 成功率)
   ```
   import pytest

@pytest.mark.asyncio
async def test_async_func():
    result = await some_async_call()
    assert result == expected
   ```
2. **** (95% 成功率)
   ```
   [pytest]
asyncio_mode = auto
This automatically treats async tests as asyncio tests.
   ```

## 无效尝试

- **** — pytest-asyncio handles the event loop; manually running can cause conflicts. (90% 失败率)
- **** — This changes the test to synchronous and may not test the intended behavior. (80% 失败率)
