# FAILED (failures=0)
# 但打印了 subTest 失败:
FAIL: test_batch (tests.test_batch.TestBatch.test_batch) (i=3)
AssertionError: 3 != 4

- **ID:** `python/unittest-subtest-failure-swallowed`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

subTest 失败记录在父测试上，但某些运行器或自定义结果类不会增加 failures 计数器，导致摘要显示 failures=0 而个别子测试实际失败。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Run with a result class that counts subtests, or use pytest which reports them:

python -m pytest tests/test_batch.py -v
   ```
2. **** (85% 成功率)
   ```
   Inspect result.failures + result.errors + subtest count in a custom runner:

result = unittest.TextTestRunner().run(suite)
assert not result.failures and not result.errors
   ```

## 无效尝试

- **** — Defeats the purpose of subTest (continue-on-failure) and stops at the first failing case. (85% 失败率)
- **** — The process may still exit 0 when failures counter is zero, so CI passes a broken suite. (90% 失败率)
