# TypeError: 'generator' object is not callable

- **ID:** `python/pytest-fixture-return-generator`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

在 pytest fixture 中使用了 yield 但忘记添加 @pytest.fixture 装饰器，导致生成器对象被当作函数调用。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.9 | active | — | — |

## Workarounds

1. **添加 @pytest.fixture 装饰器** (95% success)
   ```
   @pytest.fixture
def my_fixture():
    yield 42
   ```
2. **在测试函数参数中接收 fixture** (90% success)
   ```
   def test_func(my_fixture):
    assert my_fixture == 42
   ```

## Dead Ends

- **将 yield 改为 return，忽略 teardown** — 尝试将 fixture 改为普通函数并直接 return，但 fixture 需要 teardown 逻辑，导致资源泄漏 (70% fail)
- **在测试函数中直接调用 fixture 名称** — 在测试函数中直接调用 fixture 名称而不加括号，但 fixture 是生成器，无法被直接调用 (60% fail)
