python runtime_error ai_generated true

unittest.case._UnexpectedSuccess: test_something

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-09-25First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.8 active — — —
3.12 active — — —

Root Cause

A test marked with `@unittest.expectedFailure` passed, meaning the known bug is fixed or the test no longer fails as expected.

generic

中文

标记为 `@unittest.expectedFailure` 的测试通过了,意味着已知 bug 已修复或测试不再按预期失败。

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 50% fail

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

  2. 70% fail

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