# LoggingError: Captured log does not contain expected level 'ERROR'

- **ID:** `python/pytest-capture-logging-level-error`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

在测试中期望捕获特定级别的日志，但实际日志级别配置不正确或日志未触发。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.4.0 | active | — | — |
| 8.0.0 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   在测试中使用 `caplog.set_level(logging.ERROR)` 并确保被测代码触发 ERROR 日志。
   ```
2. **** (85% success)
   ```
   确保被测代码在特定条件下确实记录 ERROR 级别日志，例如通过 mock 或真实调用。
   ```

## Dead Ends

- **** — 可能覆盖了全局配置，且如果日志来自其他模块，设置可能无效。 (50% fail)
- **** — 日志是同步的，等待不会解决问题，且降低测试速度。 (80% fail)
