# async def 函数不被原生支持。
你需要为异步框架安装合适的插件，例如：
  - anyio
  - pytest-asyncio

- **ID:** `python/pytest-asyncio-no-mark`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

异步测试函数被收集时缺少 asyncio 标记，或 pytest-asyncio 处于 strict 模式。自 0.21 起默认 strict 模式下，每个异步测试都必须用 @pytest.mark.asyncio 装饰。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Add to pytest.ini:
  [pytest]
  asyncio_mode = auto
Or decorate each test:
  import pytest
  @pytest.mark.asyncio
  async def test_foo(): ...
   ```
2. **** (85% 成功率)
   ```
   Install and use anyio instead:
  pip install anyio
  @pytest.mark.anyio
  async def test_foo(): ...
   ```

## 无效尝试

- **** — pytest still sees an async def and refuses to run it; the wrapper never executes. (90% 失败率)
- **** — The ini option is ignored if the plugin isn't installed; error persists. (85% 失败率)
