pythondjangounit-testingtest-runner

Django Test Runner can't find tests


I am running into issues with the Django (1.10.6) Test Runner being unable to find my tests. I am using Python 3.6.

The following works:

python manage.py test apps.foo

but this does not:

python manage.py test

My project structure looks as follows:

apps/
  foo/
    migrations/
    __init__.py
    admin.py
    apps.py
    models.py
    tests.py
    urls.py
    views.py
manage.py

And tests.py looks like this:

from django.test import TestCase


class ConfirmationTests(TestCase):
    def setUp(self):
        pass

    def test_email_confirm(self):
        pass

In my settings.py:

INSTALLED_APPS = (
  ...
  'apps.foo',
)

Is there any reason why the Test Runner would fail to pick up my tests?


Solution

  • I found the issue. As suspected it was something dumb.

    I was missing a __init__.py in my apps directory.

    apps/
      foo/
        migrations/
        __init__.py
        admin.py
        apps.py
        models.py
        tests.py
        urls.py
        views.py
      __init__.py <-- the offender
    manage.py