# 失败：在 teardown 阶段找不到夹具 'client'

- **ID:** `python/pytest-fixure-teardown-error`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在 fixture 的 teardown 代码中尝试访问另一个不存在的 fixture

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   @pytest.fixture
def client():
    yield create_client()
    # teardown code
   ```
2. **** (80% 成功率)
   ```
   def client(request):
    c = create_client()
    request.addfinalizer(c.close)
    return c
   ```

## 无效尝试

- **** — teardown 阶段不应创建新 fixture (80% 失败率)
- **** — 会导致资源泄漏 (60% 失败率)
