Matched signals
- collected 0 items
- no tests ran
- exit code: 5
- exit code 5
- ExitCode.NO_TESTS_COLLECTED
- no tests were run
- ERROR: not found:
- collected 0 items / 1 error
pytest collected zero tests
What this failure means
pytest exited with code 5 because it collected zero tests. No tests matched the given path, filter expression, or marker constraint.
Symptoms
Faultline looks for one or more of these log fragments:
collected 0 items
no tests ran
exit code: 5
exit code 5
ExitCode.NO_TESTS_COLLECTED
no tests were run
ERROR: not found:
collected 0 items / 1 error
Diagnosis
pytest reserves exit code 5 for the specific condition where it starts successfully, finishes collection, and finds nothing to run. This is distinct from a collection error (exit code 2) or a test failure (exit code 1).
Common causes:
- The test path passed to pytest does not match any test files or functions.
- A
-kexpression or-mmarker filter excludes every collected item. - Test files exist but do not match the configured
python_filesorpython_functionsglob patterns. - The working directory is wrong so pytest cannot discover the test root.
testpathsinpytest.iniorpyproject.tomlpoints at a non-existent directory, or the test directory was not checked out by a shallow clone.
Fix steps
-
Run collection in dry-run mode to see what pytest discovers:
pytest --collect-only -
If using a path argument, confirm the path exists and contains test files prefixed
test_or suffixed_test.py. -
Check for an overly restrictive
-kor-mfilter in thepytestinvocation or inaddoptsinsidepytest.ini/pyproject.toml:# pyproject.toml — watch for addopts entries that exclude by default [tool.pytest.ini_options] addopts = "-m not slow" -
Verify
testpathspoints at the correct directory:python -m pytest --co -q 2>&1 | head -20 -
If the test directory requires generation or exists only on certain branches, ensure the CI job checks it out before running pytest.
Validation
pytest --collect-onlyreturns at least one test item with exit code 0.pytestexits with code 0 (tests ran) rather than code 5 (nothing collected).
Try it locally
pytest --collect-only
pytest --co -q
pytest --collect-only
How Faultline detects it
Use faultline explain pytest-no-tests to see the full playbook.
faultline analyze build.log
faultline explain pytest-no-tests
Generated from playbooks/bundled/log/test/pytest-no-tests.yaml. Do not edit directly.