# TypeError: _mock_children() 收到意外的关键字参数 'autospec'
  文件 ".../unittest/mock.py"，行 ...，在 __init__ 中
    self._mock_children = {}

- **ID:** `python/unittest-mock-autospec-call-arg`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

自定义 Mock 子类覆盖了 __init__ 但未将 **kwargs 转发给 super().__init__，导致 autospec/spec_set 等属性被静默丢弃，或在配合 `create_autospec` 时引发错误。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   from unittest.mock import Mock

class MyMock(Mock):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
   ```
2. **** (92% 成功率)
   ```
   from unittest.mock import create_autospec

mock_client = create_autospec(MyClient, instance=True)
mock_client.fetch.return_value = {"ok": True}
   ```

## 无效尝试

- **** — Loses signature checking; tests pass with typos in method names, defeating the purpose. (75% 失败率)
- **** — The subclass __init__ swallows the kwarg, so autospec is not applied. (80% 失败率)
