# PytestUnraisableExceptionWarning: 异常被忽略: <function ...>

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

## 根因

在无法传播异常的上下文中引发了异常，例如在 __del__ 方法中或垃圾回收期间。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Run pytest with -W error::pytest.PytestUnraisableExceptionWarning to turn the warning into an error and get a traceback.
   ```
2. **** (85% 成功率)
   ```
   Replace __del__ with explicit close() methods and use contextlib.closing or context managers to guarantee cleanup.
   ```

## 无效尝试

- **** — This hides the underlying issue, which may cause resource leaks or incorrect behavior. (80% 失败率)
- **** — This suppresses all warnings, potentially hiding other important issues. (90% 失败率)
