python config_error ai_generated true

已跳过:<Skipped 实例>

Skipped: <Skipped instance>

ID: python/pytest-skip-no-reason

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  1. 98% 成功率
    import pytest
    
    pytest.skip("requires GPU")
    # or
    @pytest.mark.skip(reason="not supported on Windows")
    def test_x(): ...
  2. 95% 成功率
    @pytest.mark.skipif(sys.platform == 'win32', reason='POSIX only')
    def test_x(): ...

无效尝试

常见但无效的做法:

  1. 80% 失败

    -rs shows reasons but there is none to show.

  2. 70% 失败

    xfail runs the test; may cause failures on unsupported platforms.

  3. 85% 失败

    Still lacks a reason string; message remains unhelpful.