python config_error ai_generated true

0.01s 内未运行任何测试 ERROR: 找不到文件或目录: tests/test_missing.py

no tests ran in 0.01s ERROR: file or directory not found: tests/test_missing.py

ID: python/pytest-deselect-no-tests

其他格式: JSON · Markdown 中文 · English
80%修复率
86%置信度
0证据数
2025-03-18首次发现

版本兼容性

版本状态引入弃用备注
7.x active — — —
8.x active — — —

根因分析

传给 pytest 的路径不存在,或 -k 表达式未匹配任何测试(后者通常只显示 'no tests ran' 而无文件错误)。常见于 CI 配置拼写错误或测试文件被重命名。

English

A path passed to pytest does not exist, or a -k expression matched nothing (the latter usually shows 'no tests ran' without the file error). Often caused by a typo in CI config or a renamed test file.

generic

解决方案

  1. 95% 成功率
    pytest --collect-only tests/ -q
    # check the file exists:
    ls tests/test_missing.py
    # fix the path in CI config
  2. 90% 成功率
    pytest --collect-only -q -k 'login and not slow'
    pytest -k 'login and not slow'

无效尝试

常见但无效的做法:

  1. 85% 失败

    Hides the fact that the intended test file was renamed or moved; real tests are silently skipped.

  2. 50% 失败

    Runs everything, which may be slow and may include tests that were intentionally excluded.