# Failed: fixture 'db' setup failed

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

## Root Cause

fixture在设置阶段抛出异常，导致测试无法执行。

## Version Compatibility

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

## Workarounds

1. **** (80% success)
   ```
   @pytest.fixture
def db():
    try:
        return setup_db()
    except Exception as e:
        pytest.skip(f'Database unavailable: {e}')
   ```
2. **** (90% success)
   ```
   @pytest.fixture
def db():
    db = setup_db()
    yield db
    db.close()
   ```

## Dead Ends

- **** — 测试无法运行，忽略没有意义。 (100% fail)
- **** — 根本原因是异常，不是返回值。 (80% fail)
