Django tests are not recognized

1

When running Django test commands, no tests are recognized.

My file structure is as follows:

Eagle/
  eagle/
    __init__.py
    settings.py
    urls.py
    wsgi.py
  dashboard/
    __init__.py
    admin.py
    apps.py
    forms.py
    models.py
    tests.py
    urls.py
    views.py

The content of my test file is:

from django.urls import reverse, resolve
from django.test import TestCase
from . import views


# Create your tests here.
class UrlTest(TestCase):
    def dashboard_status_code(self):
        url = reverse('dashboard')
        response = self.client.get(url)
        self.assertEquals(response.status_code, 204)

    def dashboard_view(self):
        view = resolve('/accounts/')
        self.assertEquals(view.func, views.dashboard)

I have tried to execute the following commands to test:

python manage.py test
python manage.py test dashboard
python manage.py test dashboard/
python manage.py test dashboard.tests

They all bring me the following output:

Creating test database for alias 'default'...
System check identified no issues (0 silenced).

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Destroying test database for alias 'default'...

If it helps, the code is all in GitHub ( Here ).

    
asked by anonymous 30.03.2018 / 02:16

1 answer

0

The name of the methods that are testing, should start with test_

Then it would look something like:

from django.urls import reverse, resolve
from django.test import TestCase
from . import views


# Create your tests here.
class UrlTest(TestCase):
    def test_dashboard_status_code(self):
        url = reverse('dashboard')
        response = self.client.get(url)
        self.assertEquals(response.status_code, 204)

    def test_dashboard_view(self):
        view = resolve('/accounts/')
        self.assertEquals(view.func, views.dashboard)
    
30.03.2018 / 10:40