# TypeError: assertRaises() 缺少 1 个必需的位置参数: 'callable'

- **ID:** `python/unittest-assertraises-no-context`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

`assertRaises` 以 `with self.assertRaises(ValueError):` 形式使用，但异常类型被传为字符串或可调用形式使用不当。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.9 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (97% 成功率)
   ```
   Use the context manager form correctly:
with self.assertRaises(ValueError):
    parse('bad')

Or the callable form:
self.assertRaises(ValueError, parse, 'bad')
   ```

## 无效尝试

- **** — Strings are not exception classes; raises TypeError or fails silently. (80% 失败率)
- **** — Catches all exceptions and hides real bugs. (70% 失败率)
