python runtime_error ai_generated true

unittest.case._UnexpectedSuccess: test_something

ID: python/unittest-expected-failure-unexpected-success

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  1. 95% 成功率
    Remove `@unittest.expectedFailure` and run the test; it should pass.
  2. 90% 成功率
    @unittest.skipIf(sys.version_info < (3, 10), 'requires 3.10')
    def test_something(): ...

无效尝试

常见但无效的做法:

  1. 50% 失败

    If the bug reappears, the test will fail and may be ignored.

  2. 70% 失败

    Hides the fact that the bug is fixed; the test never runs.