Skip to content
Latchkey

Django "manage.py test" vs pytest picking up no tests in CI

A CI job passes suspiciously fast because no tests actually ran. Django's manage.py test and pytest discover tests differently, so switching runners (or misconfiguring one) can silently collect zero tests and report green.

What this error means

The step logs "Ran 0 tests in 0.000s" from the Django runner, or pytest prints "collected 0 items", and the job passes without exercising anything.

Django
Ran 0 tests in 0.001s

OK

Common causes

The two runners use different discovery

Django's runner looks under a tests label and unittest naming; pytest uses testpaths and python_files. A layout that fits one may collect nothing under the other.

pytest-django not installed or wrong settings

Running pytest without pytest-django, or with a settings module that excludes the apps, yields zero collected DB tests.

How to fix it

Pick one runner and configure discovery

If you use pytest, install pytest-django and set testpaths so collection is deterministic.

pytest.ini
[pytest]
DJANGO_SETTINGS_MODULE = myproject.settings.ci
testpaths = tests
python_files = test_*.py

Assert a nonzero test count

Fail the build if collection finds nothing, so a green run always means tests ran.

Terminal
pytest --strict-markers | tee out.txt
grep -Eq "[1-9][0-9]* passed" out.txt

How to prevent it

  • Standardize on one test runner and configure its discovery explicitly.
  • Install pytest-django when using pytest against a Django project.
  • Guard against 0 collected tests so a silent pass cannot slip through.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →