Search code examples
djangodjango-rest-frameworkdjango-testing

Can not run tests in APITestCase


Structure of project

proj/
  apps/
    app1/
      ...
      tests.py
    ...
  proj/

tests.py

class UsersTestCase(APITestCase):
    def setUp(self):
        self.user = User.objects.get(id=3)
        self.client = APIClient()

    def test_users_list(self):
        ...

I run python manage.py test --settings=proj.settings.local and see Ran 0 tests in 0.000s

Why?


Solution

  • Try adding the module as test argument

    python manage.py test --settings=proj.settings.local apps.app1
    

    If it still failed, check if you have 'apps.app1' in your INSTALLED_APPS