# 夹具 'data' 被直接调用。夹具不是用来直接调用的，而是由 pytest 自动提供的。

- **ID:** `python/pytest-fixture-return-none`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

测试或夹具尝试直接调用夹具函数（如 data()），而不是将其作为参数使用，导致 pytest 引发错误，因为夹具不是常规函数。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Use the fixture as a parameter in the test function: def test_foo(data): instead of calling data().
   ```
2. **** (80% 成功率)
   ```
   If you need to call a fixture programmatically, use the request fixture: request.getfixturevalue('data')
   ```

## 无效尝试

- **** — Adding a return value to the fixture does not fix the issue because the fixture is still being called incorrectly. (70% 失败率)
- **** — Converting the fixture to a regular function may work but loses the benefits of fixture scoping and dependency injection. (50% 失败率)
