python
config_error
ai_generated
true
pytest.skip: Skipped: condition not met
ID: python/pytest-skip-vs-xfail-confusion
80%Fix Rate
86%Confidence
0Evidence
2024-05-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
Root Cause
A test was skipped using pytest.skip() when the developer intended to mark it as expected to fail (xfail). The test is not run, but the failure is not tracked.
generic中文
开发者使用 pytest.skip() 跳过测试,但本意是标记为预期失败(xfail)。测试未运行,但失败未被跟踪。
Workarounds
-
95% success
@pytest.mark.xfail(reason='Known bug #123') def test_broken(): assert False -
90% success
def test_conditional(): if not feature_enabled(): pytest.xfail('Feature not enabled') assert feature_works()
Dead Ends
Common approaches that don't work:
-
80% fail
pytest.xfail immediately fails the test, which is not the same as marking it as expected to fail. The test will be reported as failed.
-
95% fail
Comments do not change test behavior. The test remains skipped and the expected failure is not tracked.