# pytest.skip: 跳过: 条件未满足

- **ID:** `python/pytest-skip-vs-xfail-confusion`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

开发者使用 pytest.skip() 跳过测试，但本意是标记为预期失败（xfail）。测试未运行，但失败未被跟踪。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   @pytest.mark.xfail(reason='Known bug #123')
def test_broken():
    assert False
   ```
2. **** (90% 成功率)
   ```
   def test_conditional():
    if not feature_enabled():
        pytest.xfail('Feature not enabled')
    assert feature_works()
   ```

## 无效尝试

- **** — 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. (80% 失败率)
- **** — Comments do not change test behavior. The test remains skipped and the expected failure is not tracked. (95% 失败率)
