# Failed: Skipped: 你需要在 pytest.mark.skipif 中指定跳过的原因
ERROR: 未找到 tests/test_x.py::test_y 的收集器

- **ID:** `python/pytest-skipif-string-condition`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pytest.mark.skipif 需要同时提供条件和 reason 关键字。将字符串作为第一个位置参数传入（常见错误）会让 pytest 视为无效条件。

## 版本兼容性

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

## 解决方案

1. **** (98% 成功率)
   ```
   Use keyword arguments:
  @pytest.mark.skipif(sys.platform == 'win32', reason='POSIX-only')
  def test_x(): ...
   ```
2. **** (95% 成功率)
   ```
   For module-level skips:
  pytestmark = pytest.mark.skipif(condition, reason='...')
   ```

## 无效尝试

- **** — Unconditionally skips the test even on platforms where it should run. (90% 失败率)
- **** — Positional args are not supported for reason; must be keyword. (80% 失败率)
