python config_error ai_generated true

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

ID: python/pytest-deselect-no-tests

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2025-03-18First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7.x active — — —
8.x active — — —

Root Cause

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

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 85% fail

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

  2. 50% fail

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