python
runtime_error
ai_generated
true
unittest.case._UnexpectedSuccess: test_something
ID: python/unittest-expected-failure-unexpected-success
80%修复率
90%置信度
0证据数
2024-09-25首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.8 | active | — | — | — |
| 3.12 | active | — | — | — |
根因分析
标记为 `@unittest.expectedFailure` 的测试通过了,意味着已知 bug 已修复或测试不再按预期失败。
English
A test marked with `@unittest.expectedFailure` passed, meaning the known bug is fixed or the test no longer fails as expected.
解决方案
-
95% 成功率
Remove `@unittest.expectedFailure` and run the test; it should pass.
-
90% 成功率
@unittest.skipIf(sys.version_info < (3, 10), 'requires 3.10') def test_something(): ...
无效尝试
常见但无效的做法:
-
50% 失败
If the bug reappears, the test will fail and may be ignored.
-
70% 失败
Hides the fact that the bug is fixed; the test never runs.