# 使用错误：@pytest.mark.usefixtures 使用了未知的夹具 'nonexistent_fixture'

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

## 根因

在 @pytest.mark.usefixtures 中指定的夹具名称在任何 conftest.py 或测试文件中都不存在。

## 版本兼容性

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

## 解决方案

1. **Define the missing fixture in the test file or conftest.py.** (95% 成功率)
   ```
   @pytest.fixture
def nonexistent_fixture(): return 'value'
   ```
2. **Correct the fixture name to match an existing fixture.** (90% 成功率)
   ```
   @pytest.mark.usefixtures('existing_fixture')
   ```

## 无效尝试

- **Adding a fixture with the same name but wrong scope** — The fixture must be defined and accessible; scope mismatch may still cause errors. (60% 失败率)
- **Removing the usefixtures marker entirely** — If the fixture is required for test setup, tests may fail due to missing dependencies. (70% 失败率)
