python runtime_error ai_generated true

AssertionError: Test should have been skipped but was not

ID: python/unittest-skipif-condition-evaluated-false

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
0Evidence
2025-11-12First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

The skipIf condition is incorrectly evaluated, causing the test to run when it should be skipped.

generic

中文

skipIf 条件被错误评估,导致测试在应被跳过时运行。

Workarounds

  1. 95% success
    @unittest.skipIf(condition, 'reason')
    def test_foo(self):
        ...
  2. 90% success
    @pytest.mark.skipif(condition, reason='reason')

Dead Ends

Common approaches that don't work:

  1. 60% fail

    This might skip the test when it should run.

  2. 90% fail

    The test will always run, defeating the purpose.