python
config_error
ai_generated
true
已跳过:<Skipped 实例>
Skipped: <Skipped instance>
ID: python/pytest-skip-no-reason
80%修复率
90%置信度
0证据数
2024-03-30首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 7.x | active | — | — | — |
| 8.x | active | — | — | — |
根因分析
调用 pytest.skip() 时没有提供原因字符串,或使用 pytest.mark.skip 时没有 reason=,导致出现无用的 '<Skipped instance>' 消息。
English
pytest.skip() was called without a reason string, or pytest.mark.skip was used without reason=, producing an unhelpful '<Skipped instance>' message.
解决方案
-
98% 成功率
import pytest pytest.skip("requires GPU") # or @pytest.mark.skip(reason="not supported on Windows") def test_x(): ... -
95% 成功率
@pytest.mark.skipif(sys.platform == 'win32', reason='POSIX only') def test_x(): ...
无效尝试
常见但无效的做法:
-
80% 失败
-rs shows reasons but there is none to show.
-
70% 失败
xfail runs the test; may cause failures on unsupported platforms.
-
85% 失败
Still lacks a reason string; message remains unhelpful.