# RecursionError: 超出最大递归深度

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

## 根因

fixture 直接或间接依赖自身（例如 `def a(b): ...` 和 `def b(a): ...`），导致 fixture 解析期间无限递归。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## 解决方案

1. **** (85% 成功率)
   ```
   @pytest.fixture
def a(request):
    b = request.getfixturevalue('b')
    ...
   ```
2. **** (95% 成功率)
   ```
   def _common_setup(): ...

@pytest.fixture
def a():
    return _common_setup()

@pytest.fixture
def b():
    return _common_setup()
   ```

## 无效尝试

- **** — Delays the crash and may cause a segfault; does not fix the circular dependency. (90% 失败率)
- **** — If the dependency is intentional, renaming breaks the chain; if not, it may still be circular. (60% 失败率)
